cheatsheets/google_analytics.md

36 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

2013-10-14 02:36:58 +00:00
---
2013-03-25 17:44:24 +00:00
title: Google Analytics
tags: [Archived]
archived: This sheet describes an older version of Google Analytics (UA).
2013-10-14 02:36:58 +00:00
---
2013-03-25 17:44:24 +00:00
2014-02-25 10:32:14 +00:00
### Pageview
// Analytics.js
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');
2013-03-25 17:44:24 +00:00
### Track events
2014-02-25 10:32:14 +00:00
// ga.js
2013-03-25 17:44:24 +00:00
// [..., category, action, label, value (int), noninteraction (bool)]
_gaq.push(['_trackEvent', 'Videos', 'Play', 'Birthday video', true])
_gaq.push(['_trackEvent', 'Projects', 'Donate', 'Project name'])
_gaq.push(['_trackEvent', 'Accounts', 'Login'])
2014-02-25 10:32:14 +00:00
// Analytics.js
// , , category, action, label, value (int)
ga('send', 'event', 'button', 'click', 'nav buttons', 4);
2013-03-25 17:44:24 +00:00
### Variables
// [..., index, name, value, scope (optional)]
_gaq.push(['_setCustomVar', 1, 'Logged in', 'Yes', 2]);
// Scope = 1 (visitor), 2 (session), 3 (page, default)
### References
- <https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables>
- <https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide>