Tracking API: Campaign Tracking
This reference describes the methods that you use for setting up and customizing campaign tracking in Google Analytics reporting.
GATC Campaign Tracking Methods
Method Details
_setAllowAnchor()
Allows the # sign to be used as a query string delimiter in campaign tracking.
This option is disabled by default. Typically, campaign tracking URLs are
comprised of the question mark (?) separator and the ampersand (&) as delimiters
for the key/value pairs that make up the query. By enabling this option, your
campaign tracking URLs can use a pound (#) sign instead of the question mark (?).
http://mysite.net/index.html?source=In+House#method=email#offer_type=Fall+email+offers
pageTracker._setAllowAnchor(true);
parameters
Boolean enable If this parameter is set to true, then campaign will
use anchors. Else, campaign will use search strings.
_setCampContentKey()
_setCampContentKey(newCampContentKey)
Sets the campaign ad content key. The campaign content key is used to retrieve
the ad content (description) of your advertising campaign from your campaign URLs.
Use this function on the landing page defined in your campaign.
For example, suppose you have an ad on another website with this URL to your site:
http://mysite.net/index.html?source=giganoshopper.com&method=referral&offer_type=Christmas+specials&description=Garden+gloves
In this url, the key "description" delineates the content supplied in the URL for that
campaign. (These terms and phrases appear under the Ad Content column in the Campaign
detail page in the Traffic Sources report.) To use that key as your customized campaign
content key, you would set:
pageTracker._setCampContentKey("description");
parameters
String newCampContentKey New campaign content key to set.
_setCampMediumKey()
_setCampMediumKey(newCampMedKey)
Sets the campaign medium key, which is used to retrieve the medium from
your campaign URLs. The medium appears as a segment option in the Campaigns
report.
For example, suppose you have an ad on another website with this URL to your site:
http://mysite.net/index.html?source=giganoshopper.com&method=ad&offer_type=Christmas+specials&description=Garden+gloves
In this url, the key "method" delineates the medium in the URL for that
campaign. To use that key as your customized campaign content key, you would set:
pageTracker._setCampMediumKey("method");
parameters
String newCampMedKey Campaign medium key to set.
_setCampNameKey()
_setCampNameKey(newCampNameKey)
Sets the campaign name key. The campaign name key is used to retrieve
the name of your advertising campaign from your campaign URLs. You
would use this function on any page that you want to track click-campaigns on.
For example, suppose you send an email to registered users about a special
offer, and the link to that offer looks like:
http://mysite.net/index.html?source=In+House&method=email&offer_type=Fall+email+offers
In this url, the key "offer_type" delineates the name supplied in the URL for that
campaign. (This is the name that appears in the list of Campaigns in the
Traffic Sources report.) To use that key as your customized campaign name
key, you would set:
pageTracker._setCampNameKey("offer_type");
parameters
String newCampNameKey Campaign name key.
_setCampNOKey()
_setCampNOKey(newCampNOKey)
Sets the campaign no-override key variable, which is used to retrieve the campaign no-override
value from the URL. By default, this variable and its value are not set. For campaign tracking and
conversion measurement, this means that, by default, the most recent impression is the
campaign that is credited in your conversion tracking. If you prefer to associate
the first-most impressions to a conversion, you would set this method to a specific key, and in the situation where you use custom campaign variables, you would use this method to set the variable name for campaign overrides. The
no-override value prevents the campaign data from being over-written by similarly-defined
campaign URLs that the visitor might also click on.
If you have an ad on another website with this URL to your site:
http://mysite.net/index.html?source=giganoshopper.com&method=referral&offer_type=Christmas+specials&description=Garden+gloves&noo=1234
In this url, the key "noo" delineates the no-override value in the URL for that
campaign. To use that key as your customized campaign no-override key, you would set:
pageTracker._setCampNOKey("noo");
parameters
String newCampNOKey Campaign no-override key to set.
_setCampSourceKey()
_setCampSourceKey(newCampSrcKey)
Sets the campaign source key, which is used to retrieve the campaign source from
the URL. "Source" appears as a segment option in the Campaigns report.
For example, suppose you have an ad on another website with this URL to your site:
http://mysite.net/index.html?source=giganoshopper.com&method=referral&offer_type=Christmas+specials&description=Garden+gloves
In this url, the key "source" delineates the source in the URL for that
campaign. To use that key as your customized campaign source key, you would set:
pageTracker._setCampSourceKey("source");
parameters
String newCampSrcKey Campaign source key to set.
_setCampTermKey()
_setCampTermKey(newCampTermKey)
Sets the campaign term key, which is used to retrieve the campaign keywords from
the URL.
For example, suppose you have a paid ad on a search engine tagged as follow:
http://mysite.net/index.html?source=weSearch4You.com&method=paidSearchAd&offer_type=Christmas+specials&description=Garden+gloves&term=garden+tools
In this url, the key "term" delineates the keyword terms in the URL for that
campaign. To use that key as your customized campaign term key, you would set:
pageTracker._setCampTermKey("term");
parameters
String newCampTermKey Term key to set.
_setCampaignTrack()
_setCampaignTrack(enable)
Sets the campaign tracking flag. By default, campaign tracking is enabled
for standard Google Analytics set up. If you wish to disable campaign
tracking and the associated cookies that are set for campaign tracking,
you can use this method.
parameters
Boolean enable True by default, which enables campaign
tracking. If set to false, campaign tracking is disabled.
_setCookieTimeout()
_setCookieTimeout(newDefaultTimeout)
Sets the campaign tracking cookie expiration time in seconds. By default,
campaign tracking is set for 6 months. In this way, you can determine
over a 6-month period whether visitors to your site convert based on
a specific campaign. However, your business might have a longer or shorter
campaign time-frame, so you can use this method to adjust the campaign
tracking for that purpose.
pageTracker._setCookieTimeout("3152600"); //number of seconds in 1 year
parameters
String newDefaultTimeout New default cookie expiration time to set. Pass in as a string and it is converted to an integer.