1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-10-17 07:57:43 +02:00
cheatsheets/google_analytics.md
Rico Sta. Cruz 511de900ba
Formatting updates (#2133)
- Update some sheets which have very long sections
- Remove `layout: 2017/sheet` (everything has the same layout now)
- Remove outdated sheets
2024-04-03 18:30:24 +11:00

1.0 KiB

title, tags, archived
title tags archived
Google Analytics
Archived
This sheet describes an older version of Google Analytics (UA).

Pageview

// Analytics.js
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');

Track events

// ga.js
// [..., 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'])

// Analytics.js
//       ,        ,  category,  action,  label,         value (int)
ga('send', 'event', 'button',   'click', 'nav buttons', 4);

Variables

// [..., index, name, value, scope (optional)]
_gaq.push(['_setCustomVar', 1, 'Logged in', 'Yes', 2]);

// Scope = 1 (visitor), 2 (session), 3 (page, default)

References