My favorites | Sign in
Project Home Wiki Issues Source
Search
for
InstallInstructions  

Featured, Phase-Implementation
Updated Feb 17, 2010 by w.critchlow

How to integrate this script with your own Google Analytics tracking

Introduction

In order to integrate the first touch tracking functionality, you will need to be able to:

  • Import a custom .js file
  • Modify the Google Analytics embed code across your website
  • Create custom reports in GA

Note that this script writes to 4 custom variables so should be used with great care if you already use setCustomVar.

Details

Step 1

Embed a JavaScript file defining three functions:

  • distilledCheckAnalyticsCookie
  • distilledTruncate
  • distilledFirstTouch

You can embed this with the following code anywhere above the Google Analytics code script in your page code:

<script type="text/javascript" src="http://attributiontrackingga.googlecode.com/svn/trunk/distilled.FirstTouch.js"></script>

Note that if you don't want to get updated code as we improve this, you can embed the current version:

<script type="text/javascript" src="http://attributiontrackingga.googlecode.com/svn-history/r3/trunk/distilled.FirstTouch.js "></script>

This is not recommended, as the code is still a work in progress and will likely improve dramatically soon.

Step 2

Move your GA code above any Website Optimizer code or anything from Google that might write a visitor (utma) cookie and look for:

 	var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
 	pageTracker._trackPageview();

In between those two lines, you want to put the following code:

	// Distilled first touch tracking
	distilledFirstTouch(pageTracker); 

So that your trackpageview code looks like this:

 	var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
 	
	// Distilled first touch tracking
	distilledFirstTouch(pageTracker); 
	
	pageTracker._trackPageview();

Make sure you use your own UA-XXXXXXX-X identifier string!

This writes 4 custom variables (apologies for the ridiculous naming conventions - Google limits the whole of the variable name + value to 64 characters!) - note that all variables are truncated to 63 characters:

  • l = original landing page (no query string)
  • s = original landing page query string
  • r = original referrer
  • q = if q=keyword+keyword is found, this contains that part of the referrer

I have taken the full list of keyword delimiters from Google help and attempted to pull them out into the fourth variable in case the full referrer is truncated by the character limit.

Step 3

Define custom reports to make sense of all this in Google Analytics. Instructions coming soon! Read more on the Distilled blog.

Comment by robert.s...@gmail.com, Sep 28, 2010

Can you install this code on a Blogger site? Does Blogger restrict scripting? I've followed the instructions and setup a custom report as shown but I'm not seeing any custom variable values being reported.

Comment by project member w.critchlow, Oct 5, 2010

I'm afraid I don't know what blogger allows. Do you have a link to the page and I'll take a look for you?


Sign in to add a comment
Powered by Google Project Hosting