WordPress.org

Support

Support » Installation » [Plugin: Google Analytics for WordPress] Domains with two part TLDs not tracked properly

[Plugin: Google Analytics for WordPress] Domains with two part TLDs not tracked properly

  • The outbound link tracking does not work if you are linking to a domain with a two part TLD, e.g. .co.uk domains.

    Changing the ga_get_domain function to the code below resolves the issue for me:

    $hostPattern = "/^(http:\/\/)?([^\/]+)/i";
                            $domainPatternUS = "/[^\.\/]+\.[^\.\/]+$/";
                            $domainPatternUK = "/[^\.\/]+\.[^\.\/]+\.[^\.\/]+$/";
    
                            preg_match($hostPattern, $uri, $matches);
                            $host = $matches[2];
                            if (preg_match("/.*\..*\..*\..*$/",$host)) {
                                    preg_match($domainPatternUK, $host, $matches);
                            } else {
                                    preg_match($domainPatternUS, $host, $matches);
                            }
    
                            return array("domain"=>$matches[0],"host"=>$host);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Google Analytics for WordPress] Domains with two part TLDs not tracked properly’ is closed to new replies.
Skip to toolbar