google analytics attribution tracking spec
TRANSCRIPT
-
7/29/2019 Google Analytics Attribution Tracking Spec
1/12
AttributionTracking
This spec explains how to use the GoogleAnalytics cookie to track and attribute
users to their referral source (keyword,
banner ad, etc)
-
7/29/2019 Google Analytics Attribution Tracking Spec
2/12
ContentsProblem / Solution
Solution Overview
Solution Specs
-
7/29/2019 Google Analytics Attribution Tracking Spec
3/12
The ProblemWhen we drive a new user to somesite.com we cannot track the users action
beyond the form submit (sign up) using standard Google Analytics tracking.
The prevents us from identifying where the user came from. Ie, the keyword,
or ad unit that referred them to somesite.com.
We call this attribution tracking.
-
7/29/2019 Google Analytics Attribution Tracking Spec
4/12
The SolutionA custom tracking system that utilizes the Google Analytics cookie to pass
campaign variables into the somesite.com database.
Once we correlate a transaction with a referring ad ID we can attribute the
user to a specific ad source (keyword, banner ad, email, etc).
Once we have attribution tracking in place, we can measure ROI for our media
campaigns (paid search, email, SEO, social media, etc).
-
7/29/2019 Google Analytics Attribution Tracking Spec
5/12
Customer completes sign
up form at somesite.com
Prospective customer
clicks an ad or organic
listing
1
On ad click Google writes a
cookie to users browser
2
3
Tracker reads Google cookie,
extracts specific campaign
variables, and passes them
through the registration form as
hidden fields
4
ExecSight
database
Form data , including Analytics
variables, posted to database
5
Registration
Data
Solution Overview
-
7/29/2019 Google Analytics Attribution Tracking Spec
6/12
Solution SpecsWrite a custom script that extracts the following campaign variables from the
Google Analytics cookie and passes it through the lead form as a hidden field:
Utmcsr
Utmccn
Utmcmd
utmctr
Where:
utmcsr = campaign source
Utmccn = campaign name
utmcmd = campaign medium
utmctr = campaign terms
-
7/29/2019 Google Analytics Attribution Tracking Spec
7/12
Step 1 : Read CookieTo read out a cookie, call this function and pass the name of the cookie. Put the
name in a variable. First check if this variable has a value (if the cookie does not
exist the variable becomes null, which might upset the rest of your function),then do whatever is necessary.
The function receives the argument and starts.
We're going to search for the name of the cookie, followed by an =. So create
this new string and put it in nameEQ:
var x = readCookie('ppkcookie1') if (x) { [do something with x] }
function readCookie(name) {
var nameEQ = name + "=";
-
7/29/2019 Google Analytics Attribution Tracking Spec
8/12
Read Cookie ContThen split document.cookie on semicolons. ca becomes an array containing all
cookies that are set for this domain and path.
Then we go through the array (so through all cookies):
Set c to the cookie to be checked
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
while (c.charAt(0)==' ') c = c.substring(1,c.length);
-
7/29/2019 Google Analytics Attribution Tracking Spec
9/12
Read Cookie ContNow string c begins with the name of the current cookie. If this is the name of
the desired cookie
We've found what we were looking for. We now only need to return the value ofthe cookie, which is the part of c that comes after nameEQ. By returning thisvalue we also end the function: mission accomplished.
If, after having gone through all cookies, we haven't found the name we're
looking for, the cookie is not present. We return null.
if (c.indexOf(nameEQ) == 0)
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null; }
-
7/29/2019 Google Analytics Attribution Tracking Spec
10/12
Step 2: ExtractVariablesNext we need to extract the variables from the Google Analytics cookie
var utmz = readCookie('__utmz'); //using a cookie reading function
var vals = (function() {
var pairs = utmz.split('.').slice(4).join('.').split('|');
var ga = {};
for (var i = 0; i < pairs.length; i++) {
var temp = pairs[i].split('=');
ga[temp[0]] = temp[1];
}return ga;
})();
//vals.utmcmd: medium (organic, referral, direct, etc)
//vals.utmcsr: source (google, facebook.com, etc)
//vals.utmcct: content (index.html, etc)
//vals.utmccn: campaign
//vals.utmctr: term (search term)
-
7/29/2019 Google Analytics Attribution Tracking Spec
11/12
Step 3 : Pass Variablesto DatabaseModify the lead form located on the product pages to include 4 hidden fields:-
Utmcsr
Utmccn
Utmcmd
Utmctr
These fields should be alphanumeric and should not require validation. The above
fields are not required. Insert the extracted variables into their respective fields and
submit the form as normal. The hidden fields will ne captured in the registration form
and passed through to the ExecSight database.
-
7/29/2019 Google Analytics Attribution Tracking Spec
12/12
Your Contact
Dylan Touhey
CMO / Principal
250.483.7411 x 101