Online Marketing Analytics Helping Australian businesses with their web traffic
  • HomeFrontpage
  • Contact Us
  • Google Analytics Terms Glossary
Home » Analytics Hacks » Tag Your Visitors With Cookie Hacks
Jul, Thu 23rd, 2009 Posted in : Analytics Hacks By : admin 4 Comments

If you haven’t already noticed, I have been researching quite a bit regarding hacking up the standard Google Analytics code, specifically how cookies are set, in order to further refine the data that you are collecting. This week was inspired off a post from the Official Google Analytics Blog outlining a few tips regarding adding demographic data to the numbers, giving them more meaning.

I want to take it in a little bit of a different direction. I find it difficult (probably as most bloggers do) to generate feedback on my posts in the form of comments or tracbacks. And to be honest, I can’t really determine what would influence someone to leave a comment versus someone who reads regularly. The more experienced bloggers would be able to give me a clear answer, however I am going to try to work it out with Google Analytics.

Modifying the GA Code – setVar

The answer lies with the pageTracker._setVar() function of the Analytics API. What this function does according to the documentation is allow you to create custom variables that you can tag your visitors with when they visit your website. It adds it to the __utmv cookie and lasts for 2 years.

How we are going to do it today is everytime someone comments on a blog that I author for, it will tag that visitor as a “commenter”. That will allow me to monitor their movement through the website and determine any correlations between commenters, return visitors and converters.

How do we do it in WordPress?

Very easily in fact. Look for the file that generates your comments template and styling. Generally it is in your theme directory and the comments.php file.

Much like all the other Javascript function calls, I will be attaching it as an onclick event on the submit button. We make the assumption that someone has filled in all the key elements of the comment (name, email, the comment itself) and is now ready to submit. Whether the person is a spammer or not, or even if the comment is approved or not does not matter. The fact is someone (or something) was motivated enough to leave something behind on their visit.

My submit button code now looks like this:


After about 24 hours or so, you will be able to view your Google Analytics User Defined Reports and see that information in there. For further refinement you can even set up a separate profile to generate reports specific to their actions across the website.

Tune in next week as I further dig around the cookie structures of Analytics and see what other gems are in store. After a few months of data collection, I will be giving tips on what to do with the data once we have collected it.

4 Responses to Tag Your Visitors With Cookie Hacks

Click here to cancel reply.

Leave a Reply

Post Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Posts

  • Don’t Get Greedy With Regex
  • Google Analytics is Faster
  • Using GA to find out Ranking History
  • Google Analytics Gets Clever
  • When Things are Not Set
(C) 2010 Versatile - Business & Portfolio Wordpress Theme by system32