[!NOTE]
analytics.js(Universal Analytics) siga.jssunt biblioteci istorice inlocuite de Google Analytics 4 (GA4 pringtag.js). Acest ghid serveste ca referinta de arhiva.
Universal Analytics (analytics.js)
Afisari de pagina (Pageviews)
ga('create', 'UA-XXXX-Y', 'auto')
ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' })
ga('send', 'pageview')
ga('send', 'pageview', { 'dimension15': 'My custom dimension' })
Urmarirea evenimentelor (Event Tracking)
ga('send', 'event', 'button', 'click', { color: 'red' });
ga('send', 'event', 'button', 'click', 'nav buttons', 4);
/* ^category ^action ^label ^value (int) */
Urmarirea exceptiilor (Exception Tracking)
ga('send', 'exception', {
exDescription: 'DatabaseError',
exFatal: false,
appName: 'myapp',
appVersion: '0.1.2'
})
Google Analytics clasic (ga.js)
Sintaxa arhivata pentru fragmente istorice de urmarire ga.js.
Urmarirea evenimentelor (Event Tracking)
// [..., 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']);
Variabile personalizate (Custom Variables)
// [..., index (1-5), name, value, scope (optional)]
_gaq.push(['_setCustomVar', 1, 'Logged in', 'Yes', 2]);
// Domeniu Scope: 1 (vizitator), 2 (sesiune), 3 (pagina, implicit)