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

  1. Lee Willis
    Posted 6 years ago #

    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);
  2. Joost de Valk
    Posted 6 years ago #

    Added in 3.2.1 :) Thanks for the patch!

Topic Closed

This topic has been closed to new replies.

About this Topic