05/22 - Cheat Sheet: Universal Analytics
 Share
The version of the browser you are using is no longer supported. Please upgrade to a supported browser.Dismiss

 
$
%
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
|
 
Still loading...
ABCD
1
Universal Analytics Cheat Sheet - Dev Guide
2
by Nicholas Blexrud
3
http://twitter.com/nicholasblexrud
4
5
Advanced Configuration
6
Create a trackerga('create', 'UA-XXXX-Y');
7
Sends a pageviewga('send', 'pageview');
8
Set a parameter ga('set','pageview', '/my-custom-page');
9
Create multiple trackersga('create', 'UA-XXXX-Y');
ga('create', 'UA-XXXX-Y', { 'name' : 'newTracker'}); // New tracker
10
Send pageview to both trackersga('send', 'pageview');
ga('newTracker.send', 'pageview'); // Send page view for new tracker.
11
Anonymize IPga('set', 'anonymizeIP', true);
12
User Opt-outwindow['ga-disable-UA-XXXX-Y'] = true;
13
14
15
16
Page Tracking
17
Sends virtual pageviewga('send', 'pageview');
18
Sends virtual pageview and titlega('send', 'pageview', {
'page' : '/my-overridden-page?id=1',
'title' : my overridden page'
});
19
With field namesga('send', {
'hitType' : 'pageview',
'page' : '/my-overridden-page?id=1',
'title' : 'my overridden page'
});
20
21
22
23
Event Tracking
24
Sends event (basic)ga('send', 'event', 'category', 'action')
25
Sends event (w/label & value)ga('send', 'event', 'category', 'action', 'opt_label', opt_value);
26
Sends event w/o impacting bounce ratega('send', 'event', 'category', 'action', {nonInteraction' : 1});
27
With field namesga('send', {
'hitType' : 'event', // Required.
'eventCategory' : 'button', // Required.
'eventAction' : 'click', // Required.
'eventLabel' : 'nav buttons',
'eventValue' : 4
});
28
29
30
31
32
Ecommerce
33
load the ecommerce pluginga('require','ecommerce','ecommerce.js');
34
add transaction data to cartga('ecommerce:addTransaction', {
'id' : '1234', // Transaction ID. Required.
'affiliation' : 'Acme Clothing', // Affiliation or store name.
'revenue' : '11.99', // Grand Total.
'shipping' : '5', // Shipping.
'tax' : '1.29' // Tax.
});
35
add items to the shopping cartga('ecommerce:addItem', {
'id' : '1234', // Transaction ID. Required.
'name' : 'Fluffy Pink Bunnies', // Product name. Required.
'sku' : 'DD23444', // SKU/code.
'category' : 'Party Toys', // Category or variation.
'price' : '11.99', // Unit price.
'quantity' : '1' // Quantity.
});
36
send ecommerce dataga('ecommerce:send');
37
clear shopping cartga('ecommerce:clear');
38
set currency codesga('set','currencyCode','EUR');
39
40
41
42
Social Interactions
43
send a social interactionsga('send', 'social', 'socialNetwork', 'socialAction', 'socialtarget');
44
With field namesga('send', {
'hitType': 'social',
'socialNetwork': 'facebook',
'socialAction': 'like',
'socialTarget': 'http://mycoolpage.com',
'page': '/my-new-page'
});
45
46
47
48
User Timings
49
send user timing dataga('send', 'timingCategory', timingVar', timingValue, 'opt_timingLabel');
50
With field namesga('send', {
'hitType': 'timing',
'timingCategory': 'jQuery',
'timingVar': 'Load Library',
'timingValue': 20,
'timingLabel': 'Google CDN',
'page': '/my-new-page'
});
51
52
53
54
Custom Dimensions & Metrics
55
Send custom dimension for a pageviewga('send', 'pageview', {
'dimension15' : 'My Custom Dimension'
});
56
Send custom metric for eventga('send', 'event', 'category', 'action', {
'metric18' : 8000
});
57
Send custom metric with decimalsga('send', 'event', 'category', 'action', {
'metric19': 24.99
});
58
Set custom dimensionga('set', 'dimension5', 'custom data');
59
Set values for both dimensions and metricga('set', {
'dimension5' : 'custom dimension data',
'metric5' : 'custom metric data'
});
60
61
62
63
Domains & Cookies
64
Modifying Cookie valuesga('create', 'UA-XXXX-Y', {
'cookieName': 'new_cookie_name'
'cookieDomain': 'mynew.domain.com',
'cookieExpires': 60 * 60 * 24 * 28 // Time in seconds.
});
65
Create Cookie for localhostga('create', 'UA-XXXX-Y', {
'cookieDomain': 'none'
});
66
Create Cookie for multiple sub domains// Configuration for one.example.com
ga('create', 'UA-XXXX-Y' {'cookieDomain': 'example.com'});

// Configuration for two.example.com
ga('create', 'UA-1234-5' {'cookieDomain': 'example.com'});
67
Modifying Cookie Expirationga('create', 'UA-XXXX-Y', {
'cookieExpires': 60
});
68
Disabling Cookiesga('create', 'UA-XXXX-Y', {
'storage': 'none',
'clientId', '35009a79-1a05-49d7-b876-2b884d0f825b'
});
69
Loading...
 
 
 
Universal Analytics - Dev Guide
Universal Analytics - Method & Field Reference
Universal Analytics - Limits & Quotas