Home  |   Blog  |   SEO  |   About  |   éŕéř ář-ŕĺď  |  

Archive for the ‘google analytics’ Category

Track non HTML files with Google Analytics

Thursday, May 29th, 2008

Google Analytics is based on Javascript. Since Javascript can be placed only in HTML files, tracking non HTML files like pdf, zip, mp3 and others is a little bit tricky. But it is possible.

In order for Google Analytics track downloads of an mp3 file from your site, do the following:

1. Add the Google Analitycs tracking code ABOVE the the link to your downloaded file. If you already have the Google Analytics code in your site footer, and you probably do, place the same code again, but remove the call to _trackPageview().

example:

<script type=”text/javascript”>
var gaJsHost = ((”https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(”%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-xxxyyyy-z”);
pageTracker._initData();
</script>

2. Edit every link you want to track, in the following way:
In case your link looks like this:

<a href=”/downloads/file1.mp3″>Hava Nagila</a>

change it to look like that:

<a href=”/downloads/file1.mp3″ onClick=”javascript: pageTracker._trackPageview(’/downloads/HavaNagila’); >Hava Nagila</a>

The clicks on this link will appear in Google Analytics as if the page /downloads/HavaNagila was actually viewed, even though there isn’t really such a page.

You can read more about this issue and others in Google Help Center.

DiggRedditSlashdotTwitThisSphinnStumbleUpondel.icio.usFacebookGoogleTechnoratiE-mail this story to a friend!

Disable Google Analytics

Sunday, March 16th, 2008

I’m using Google analytics quite a lot on every site I work on. Recently we had a problem at one of my customers sites, where the marketing people working in that company were browsing their website all day, searching in Google their website keywords again and again, and made Google Analytics reports become unreliable. There were so many visits in the reports that were not real customers but our own staff, that we didn’t really know which part of the report was real and which part was our own tracks.

Like in every crime scene, we just needed our guys to put on gloves before touching everything…

The solution was very simple.

1. We created a file called disable_analytcis.php

<?php
SetCookie(”disable_analytics”,”1″ ,time()+91536000,”/”);
echo “Yuhu!, Google analytics is disabled!”;
?>

2. In the site footer, next to the Google analytics code, we added this:

<?
if (!empty($_COOKIE[’disable_analytics’]))
{
echo “Google analytics is disabled”;
}
else
{
?>
//put google analytics code here…
<?
}
?>

That was easy. The hard part was to send the link to disable_analytics.php to all the sales and marketing in that company and ask them to click on the link. They ALL wanted to know exactly WTF is going on here… are we spying on them? yes? no? what do you mean Google keeps track??? anonymous? who authorized this… :)

Once everybody got their cookie, our statistics cleared up. Real client analytics emerged and logs turned useful again. When you do it on your site, make sure your cookie gets to all computers, home computers, laptops and any computer that you don’t want to track.

update: (Thanks Pieter!)
Google offers cookie based filters, as described in Google Analytics Help Center:
Create an Exclude filter to remove data from visitors with this cookie. Follow these instructions to create a filter with the following settings:
Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: disable_analytics
Case Sensitive: No

DiggRedditSlashdotTwitThisSphinnStumbleUpondel.icio.usFacebookGoogleTechnoratiE-mail this story to a friend!



Vulnerability Scanner