Google Analytics - Tracker

Card Puncher Data Processing

About

What is a user-event tracker ? (Analytics Script) in Google analytics

Tracker objects (also known as “trackers”) are objects that can collect and store data and then send that data to Google Analytics.

Management

Create

doc

// Queues a named tracker object for creation.
ga('create', 'UA-XXXXX-Y', 'auto', 'myTracker');

where:

Initialization

  • If a cookie does not exist for the specified domain, a client ID is generated and stored in the cookie.
  • the tracker will gather the browsing context (page, url, screen,…)

Get

Getting a reference to a tracker object requires waiting until after the create command has been executed with the ready callback

  • When using only one tracker (default)
ga(function(tracker) {
  console.log(tracker); 
});
  • when using more than one
ga(function() {
  console.log(ga.getByName('myTracker'));
});

Get Name

The default trackers are given the name “t0”.

ga(function(tracker) {
  console.log(tracker.get('name'));
});

Get properties

by name

ga(function(tracker) {
  console.log(tracker.get('name'));
  console.log(tracker.get('clientId'));
  console.log(tracker.get('referrer'));
});

where:

by id defined in the measurement protocol

ga(function(tracker) {
  console.log(tracker.get('&dt'));
});

// same as
ga(function(tracker) {
  console.log(tracker.get('title'));
});

where:

Set properties

  • On the default tracker
ga('set', {
  page: '/about',
  title: 'About Us'
});
// or
ga(function(tracker) {
  tracker.set('page', '/about');
});
  • on a named tracker
ga('myTracker.set', 'page', '/about');

List

ga('create', 'UA-XXXXX-Y', 'auto', 'tracker1');
ga('create', 'UA-XXXXX-Z', 'auto', 'tracker2');

ga(function() {
  // Logs an array of all tracker objects.
  console.log(ga.getAll());
});

Exist

When there is no default tracker, the first argument of the ready callback is undefined

ga(function(tracker) {
  console.log(tracker); // Logs `undefined`.
});

Send

Each time the send command is called, analytics.js executes a sequence of tasks to validate, construct, and send a measurement protocol request from the user's browser to Google Analytics.

See:

  • The table that describes each of these tasks, in the order they are executed.
  • how to add, abort, set a task

Documentation / Reference





Discover More
Card Puncher Data Processing
Google Analytics (ga)

from Google ga() is tracking snippet. It's implemented as a javascript global function known as the command queue If the ga() command queue receives a command it doesn't recognize, it simply ignores...
Card Puncher Data Processing
Google Analytics - User Identification

in Google Analytics for a The user id is the named id (the id of your application) You can specify a user id when creating a tracker. from doc...



Share this page:
Follow us:
Task Runner