Joudicek Jouda
Joudicek Jouda

Reputation: 792

Checking presence of Google Analytics code on given domain

I've made a simple PHP script for checking Google Analytics code on given web page (i.e. I want to simply test if client has GA installed at all):

if (isset($_GET['given_domain']))
{
  $domain = $_GET['given_domain'];
  if (!is_valid_domain_name($domain))
  {
    $content = "_gaq.push";
    $content_tag = "script";

    set_time_limit(0);

    $doc = new DOMDocument();

    @$doc->loadHTMLFile($domain);
    $found = false;

    foreach($doc->getElementsByTagName($content_tag) as $tag) {
        if (strpos($tag->nodeValue, $content) !== false) {
            $found = true;
            break;
        }
    }
    if ($found == true) echo '<span style="background: green;">'.$domain.'</span>: GA found'; else echo '<span style="background: red;">'.$domain.'</span>: GA NOT found!';
  }
  else
    echo ("Enter domain");
}

It works correctly on:

http://fivepaths.com (Found)
http://www.ebay.com (NOT found)
...

But when I try this, it gives me FOUND, but when I open the HTML code and try to CTRL+F "gaq" there is nothing.

Where is the problem?

Upvotes: 0

Views: 128

Answers (1)

Ryan decosta
Ryan decosta

Reputation: 455

i had found that the google analytics on the above mentioned url is coming from the js file http://www.hezkycesky.com/sites/all/modules/google_analytics/googleanalytics.js?munwaf

Upvotes: 1

Related Questions