Google Analytics

Analytics.js Field Reference

This document lists all of the configurable field names for analytics.js.

  1. Create Only Fields
  2. General
  3. Session
  4. Traffic Sources
  5. System Info
  6. Hit
  7. Content Information
  8. App Tracking
  9. Event Tracking
  10. Social Interactions
  11. Timing
  12. Exceptions
  13. Custom Dimensions / Metrics
  14. Content Experiments

Create Only Fields

The following fields may only be set in the create method. For more details, read the Creating Tracker Objects section in the Advanced Configuration Guide.

Tracker Name

Optional. This may only be set in the create method.

Name of the tracker object.

Field Name Value Type Default Value
name text t0
Example value: myTracker
Example usage:
ga('create', 'UA-XXXX-Y', {'name': 'myTracker'});

Client ID

Required for all hit types.

Anonymously identifies a browser instance. By default, this value is stored as part of the first-party analytics tracking cookie with a two-year expiration.

Field Name Value Type Default Value
clientId text Randomly Generated
Example value: 35009a79-1a05-49d7-b876-2b884d0f825b
Example usage:
ga('create', 'UA-XXXX-Y', {
  'clientId': '35009a79-1a05-49d7-b876-2b884d0f825b'
});

User ID

Optional. This may only be set in the create method.

This is intended to be a known identifier for a user provided by the site owner/tracking library user. It may not itself be PII. The value should never be persisted in GA cookies or other Analytics provided storage.

Field Name Value Type Default Value
userId text None
Example value: as8eknlll
Example usage:
ga('create', 'UA-XXXX-Y', {
  'userId': 'as8eknlll'
});

Sample Rate

Optional. This may only be set in the create method.

Specifies what percentage of users should be tracked. This defaults to 100 (no users are sampled out) but large sites may need to use a lower sample rate to stay within Google Analytics processing limits.

Field Name Value Type Default Value
sampleRate float 100
Example value: 5
Example usage:
ga('create', 'UA-XXXX-Y', {'sampleRate': 5});

Site Speed Sample Rate

Optional. This may only be set in the create method.

This setting determines how often site speed tracking beacons will be sent. By default, 1% of users will be automatically be tracked.

Field Name Value Type Default Value
siteSpeedSampleRate integer 1
Example value: 50
Example usage:
ga('create', 'UA-XXXX-Y', {'siteSpeedSampleRate': 50});

Always Send Referrer

Optional. This may only be set in the create method.

By default the HTTP referrer URL, which is used to attribute traffic sources, is only sent when the hostname of the referring site differs from the hostname of the current page. Enable this setting only if you want to process other pages from your current host as referrals.

Field Name Value Type Default Value
alwaysSendReferrer boolean false
Example value: true
Example usage:
ga('create', 'UA-XXXX-Y', {'alwaysSendReferrer': true});

Allow Anchor Parameters

Optional. This may only be set in the create method.

By default, analytics.js will search for custom campaign parameters such as utm_source, utm_medium, etc. in both the query string and anchor of the current page's URL. Setting this field to false will result in ignoring any custom campaign parameters that appear in the anchor.

Field Name Value Type Default Value
allowAnchor boolean true
Example value: false
Example usage:
ga('create', 'UA-XXXX-Y', {'allowAnchor': false});

Cookie Name

Optional. This may only be set in the create method.

Name of the cookie used to store analytics data

Field Name Value Type Default Value
cookieName text _ga
Example value: gaCookie
Example usage:
ga('create', 'UA-XXXX-Y', {'cookieName': 'gaCookie'});

Cookie Domain

Optional. This may only be set in the create method.

Specifies the domain used to store the analytics cookie. Setting this to 'none' sets the cookie without specifying a domain.

Field Name Value Type Default Value
cookieDomain text document.location.hostname (normalized)
Example value: example.com
Example usage:
ga('create', 'UA-XXXX-Y', {'cookieDomain': 'example.com'});

Cookie Expiration

Optional. This may only be set in the create method.

Specifies the cookie expiration, in seconds.

Field Name Value Type Default Value
cookieExpires integer 63072000 (two years)
Example value: 86400
Example usage:
ga('create', 'UA-XXXX-Y', {'cookieExpires': 86400});

Legacy Cookie Domain

Optional. This may only be set in the create method.

This field is used to configure how analytics.js searches for cookies generated by earlier Google Analytics tracking scripts such as ga.js and urchin.js.

Field Name Value Type Default Value
legacyCookieDomain text None
Example value: store.example.com
Example usage:
ga('create', 'UA-XXXX-Y', {'legacyCookieDomain': 'store.example.com'});

General

Anonymize IP

Optional.

When present, the IP address of the sender will be anonymized.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
anonymizeIp aip boolean None N/A all
Example value: true
Example usage:
ga('set', 'anonymizeIp', true);

Force SSL

Optional.

By default, tracking beacons sent from https pages will be sent using https while beacons sent from http pages will be sent using http. Setting forceSSL to true will force http pages to also send all beacons using https.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
forceSSL None boolean false N/A all
Example value: true
Example usage:
ga('set', 'forceSSL', true);

Hit Callback

Optional.

A function that will be called after processing a hit. This callback is designed to always be called, either directly after a hit is sent succussfully or when it has been determined that a hit cannot be sent or has failed to send. No arguments are passed to the function when called.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
hitCallback None function None None all
Example usage:
// Alerts the user when a hit is sent.
ga('send', 'pageview', {
  'hitCallback': function() {
    alert('hit sent');
  }
});

Session

Session Control

Optional.

Used to control the session duration. A value of 'start' forces a new session to start with this hit and 'end' forces the current session to end with this hit. All other values are ignored.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
sessionControl sc text None None all
Example value: start
Example usage:
// Starts a new session.
ga('send', 'pageview', {'sessionControl': 'start'});

Traffic Sources

Document Referrer

Optional.

Specifies which referral source brought traffic to a website. This value is also used to compute the traffic source. The format of this value is a URL. This field is initialized by the create command and is only set when the current hostname differs from the referrer hostname, unless the 'alwaysSendReferrer' field is set to true.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
referrer dr text document.referrer 2048 Bytes all
Example value: http://example.com
Example usage:
ga('set', 'referrer', 'http://example.com');

Campaign Name

Optional.

Specifies the campaign name.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
campaignName cn text None 100 Bytes all
Example value: (direct)
Example usage:
ga('set', 'campaignName', '(direct)');

Campaign Source

Optional.

Specifies the campaign source.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
campaignSource cs text None 100 Bytes all
Example value: (direct)
Example usage:
ga('set', 'campaignSource', '(direct)');

Campaign Medium

Optional.

Specifies the campaign medium.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
campaignMedium cm text None 50 Bytes all
Example value: organic
Example usage:
ga('set', 'campaignMedium', 'organic');

Campaign Keyword

Optional.

Specifies the campaign keyword.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
campaignKeyword ck text None 500 Bytes all
Example value: Blue Shoes
Example usage:
ga('set', 'campaignKeyword', 'Blue Shoes');

Campaign Content

Optional.

Specifies the campaign content.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
campaignContent cc text None 500 Bytes all
Example value: content
Example usage:
ga('set', 'campaignContent', 'content');

Campaign ID

Optional.

Specifies the campaign ID.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
campaignId ci text None 100 Bytes all
Example value: ID
Example usage:
ga('set', 'campaignId', 'ID');

System Info

Screen Resolution

Optional.

Specifies the screen resolution. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
screenResolution sr text None 20 Bytes all
Example value: 800x600
Example usage:
ga('set', 'screenResolution', '800x600');

Viewport size

Optional.

Specifies the viewable area of the browser / device. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
viewportSize vp text None 20 Bytes all
Example value: 123x456
Example usage:
ga('set', 'viewportSize', '123x456');

Document Encoding

Optional.

Specifies the character set used to encode the page / document. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
encoding de text UTF-8 20 Bytes all
Example value: UTF-8
Example usage:
ga('set', 'encoding', 'UTF-16');

Screen Colors

Optional.

Specifies the screen color depth. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
screenColors sd text None 20 Bytes all
Example value: 24-bits
Example usage:
ga('set', 'screenColors', '8-bit');

User Language

Optional.

Specifies the language. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
language ul text None 20 Bytes all
Example value: en-us
Example usage:
ga('set', 'language', 'en-us');

Java Enabled

Optional.

Specifies whether Java was enabled. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
javaEnabled je boolean None N/A all
Example value: true
Example usage:
ga('set', 'javaEnabled', true);

Flash Version

Optional.

Specifies the flash version. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
flashVersion fl text None 20 Bytes all
Example value: 10 1 r103
Example usage:
ga('set', 'flashVersion', '10 1 r103');

Hit

Hit type

Required for all hit types.

The type of hit. Must be one of 'pageview', 'screenview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
hitType t text None None all
Example value: pageview
Example usage:
ga('send', {
  'hitType': 'pageview',
  'page': '/home'
});

Non-Interaction Hit

Optional.

Specifies that a hit be considered non-interactive.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
nonInteraction ni boolean None N/A all
Example value: true
Example usage:
ga('set', 'nonInteraction', true);

Content Information

Document location URL

Optional.

Specifies the full URL (excluding anchor) of the page. This field is initialized by the create command.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
location dl text None 2048 Bytes all
Example value: http://foo.com/home?a=b
Example usage:
ga('set', 'location', 'http://foo.com/home?a=b');

Document Host Name

Optional.

Specifies the hostname from which content was hosted.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
hostname dh text None 100 Bytes all
Example value: foo.com
Example usage:
ga('set', 'hostname', 'foo.com');

Document Path

Optional.

The path portion of the page URL. Should begin with '/'. Used to specify virtual page paths.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
page dp text None 2048 Bytes all
Example value: /foo
Example usage:
ga('set', 'page', '/foo');

Document Title

Optional.

The title of the page / document. Defaults to document.title.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
title dt text None 1500 Bytes all
Example value: Settings
Example usage:
ga('set', 'title', 'Settings');

Screen Name

Optional.

If not specified, this will default to the unique URL of the page by either using the &dl parameter as-is or assembling it from &dh and &dp. App tracking makes use of this for the 'Screen Name' of the screenview hit.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
screenName cd text None 2048 Bytes all
Example value: High Scores
Example usage:
ga('set', 'screenName', 'High Scores');

Link ID

Optional.

The ID of a clicked DOM element, used to disambiguate multiple links to the same URL in In-Page Analytics reports when Enhanced Link Attribution is enabled for the property.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
linkid linkid text None None all
Example value: nav_bar
Example usage:
ga('set', '&linkid', 'html-element-id');

App Tracking

Application Name

Optional.

Specifies the application name.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
appName an text None 100 Bytes all
Example value: My App
Example usage:
ga('set', 'appName', 'My App');

Application ID

Optional.

Application identifier.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
appId aid text None 150 Bytes all
Example value: com.company.app
Example usage:
ga('set', 'appId', 'com.company.app');

Application Version

Optional.

Specifies the application version.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
appVersion av text None 100 Bytes all
Example value: 1.2
Example usage:
ga('set', 'appVersion', '1.2');

Application Installer ID

Optional.

Application installer identifier.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
appInstallerId aiid text None 150 Bytes all
Example value: com.platform.vending
Example usage:
ga('set', 'appInstallerId', 'com.platform.vending');

Event Tracking

Event Category

Optional.

Specifies the event category. Must not be empty.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
eventCategory ec text None 150 Bytes event
Example value: Category
Example usage:
ga('send', 'event', {
  'eventCategory': 'Category',
  'eventAction': 'Action'
});

Event Action

Optional.

Specifies the event action. Must not be empty.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
eventAction ea text None 500 Bytes event
Example value: Action
Example usage:
ga('send', 'event', {
  'eventCategory': 'Category',
  'eventAction': 'Action'
});

Event Label

Optional.

Specifies the event label.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
eventLabel el text None 500 Bytes event
Example value: Label
Example usage:
ga('send', 'event', {
  'eventCategory': 'Category',
  'eventAction': 'Action',
  'eventLabel': 'Label'
});

Event Value

Optional.

Specifies the event value. Values must be non-negative.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
eventValue ev integer None None event
Example value: 55
Example usage:
ga('send', 'event', {
  'eventCategory': 'Category',
  'eventAction': 'Action',
  'eventValue': 55
});

Social Interactions

Social Network

Required for social hit type.

Specifies the social network, for example Facebook or Google Plus.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
socialNetwork sn text None 50 Bytes social
Example value: facebook
Example usage:
ga('send', 'social', {
  'socialNetwork': 'facebook',
  'socialAction': 'like',
  'socialTarget': 'http://foo.com'
})

Social Action

Required for social hit type.

Specifies the social interaction action. For example on Google Plus when a user clicks the +1 button, the social action is 'plus'.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
socialAction sa text None 50 Bytes social
Example value: like
Example usage:
ga('send', 'social', {
  'socialNetwork': 'facebook',
  'socialAction': 'like',
  'socialTarget': 'http://foo.com'
})

Social Action Target

Required for social hit type.

Specifies the target of a social interaction. This value is typically a URL but can be any text.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
socialTarget st text None 2048 Bytes social
Example value: http://foo.com
Example usage:
ga('send', 'social', {
  'socialNetwork': 'facebook',
  'socialAction': 'like',
  'socialTarget': 'http://foo.com'
})

Timing

User timing category

Optional.

Specifies the user timing category.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
timingCategory utc text None 150 Bytes timing
Example value: category
Example usage:
ga('send', 'timing', {
  'timingCategory': 'category',
  'timingVar': 'lookup',
  'timingValue': 123
});

User timing variable name

Optional.

Specifies the user timing variable.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
timingVar utv text None 500 Bytes timing
Example value: lookup
Example usage:
ga('send', 'timing', {
  'timingCategory': 'category',
  'timingVar': 'lookup',
  'timingValue': 123
});

User timing time

Optional.

Specifies the user timing value. The value is in milliseconds.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
timingValue utt integer None None timing
Example value: 123
Example usage:
ga('send', 'timing', {
  'timingCategory': 'category',
  'timingVar': 'lookup',
  'timingValue': 123
});

User timing label

Optional.

Specifies the user timing label.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
timingLabel utl text None 500 Bytes timing
Example value: label
Example usage:
ga('send', 'timing', {
  'timingCategory': 'category',
  'timingVar': 'lookup',
  'timingValue': 123,
  'timingLabel': 'label'
});

Exceptions

Exception Description

Optional.

Specifies the description of an exception.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
exDescription exd text None 150 Bytes exception
Example value: DatabaseError
Example usage:
ga('send', 'exception', {
  'exDescription': 'DatabaseError'
});

Is Exception Fatal?

Optional.

Specifies whether the exception was fatal.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
exFatal exf boolean 1 N/A exception
Example value: true
Example usage:
ga('send', 'exception', {
  'exFatal': true
});

Custom Dimensions / Metrics

Custom Dimension

Optional.

Each custom dimension has an associated index. There is a maximum of 20 custom dimensions (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
dimension cd[1-9][0-9]* text None 150 Bytes all
Example value: Sports
Example usage:
ga('set', 'dimension14', 'Sports');

Custom Metric

Optional.

Each custom metric has an associated index. There is a maximum of 20 custom metrics (200 for Premium accounts). The name suffix must be a positive integer between 1 and 200, inclusive.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
metric cm[1-9][0-9]* integer None None all
Example value: 47
Example usage:
ga('set', 'metric7', 47);

Content Experiments

Experiment ID

Optional.

This parameter specifies that this user has been exposed to an experiment with the given ID. It should be sent in conjunction with the Experiment Variant parameter.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
expId xid text None 40 Bytes all
Example value: Qp0gahJ3RAO3DJ18b0XoUQ
Example usage:
ga('set', 'expId', 'Qp0gahJ3RAO3DJ18b0XoUQ');

Experiment Variant

Optional.

This parameter specifies that this user has been exposed to a particular variation of an experiment. It should be sent in conjunction with the Experiment ID parameter.

Field Name Protocol Parameter Value Type Default Value Max Length Supported Hit Types
expVar xvar text None None all
Example value: 1
Example usage:
ga('set', 'expVar', '1');

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.