Campaign Tracking - Web Tracking (ga.js)

Overview

This document covers how to customize the elements that are displayed in the Traffic Sources section of the Google Analytics reporting interface. Google Analytics tracks traffic to your website from two basic referring sources:

  • Organic campaigns
    From an unpaid search engine results link, a referral from another website (such as a blog), and direct traffic.
  • Paid campaigns
    From Google Ads, paid search engine keywords, or non-Google Ads providers.

After a user reaches your site from one of these sources, that user's visit is tagged with a campaign tracking cookie as coming from that source.

Campaign Tracking

In its broadest definition, campaign tracking refers to a method of identifying how users discover your site. Specifically, you use campaign tracking in Google Analytics to accurately track online advertising campaigns to your website, both from Google Ads generated campaigns as well as from other advertising sources. You can use some of the campaign tracking customizations to adjust whether subsequent ad referrals override earlier referrals to your site, either organic or paid.

Before configuring campaign tracking using the ga.js campaign tracking settings, you should understand how campaign tracking works in general and how you can best use it to track advertising referrals to your site. The following table lists a number of articles in the Help Center that describe campaign tracking. The rest of this section describes campaign tracking settings specific to the ga.js tracking code.

Article Description
About Campaigns Describes the process of campaign tracking, from setting up and parsing a link, to logging campaign data in the Analytics reporting and associating campaigns with goals in order to track user conversion.
Tagging Your Destination URLs Describes how to enable/disable auto-tagging for your Google Ads campaigns and provides information for how to manually tag destination URLs.
URL Builder Tool Tool you can use to automatically generate a campaign tracking URL if necessary.
Best Practices for Tagging Links Describes how to employ effective link tagging for non-Google Ads campaigns. See the information in this section for details on how to use ga.js method calls to use your own campaign tracking variables with this model.
Campaigns and traffic sources Describes how Google Analytics collects, processes, and reports campaign and traffic source data.

General Campaign Features

Use these methods to control general characteristics of campaign behavior on your entire site or a set of pages.

Feature Method Description
Disable Campaign Tracking _setCampaignTrack() Campaign tracking is enabled by default, but you can use this method to disable campaign tracking and its associated cookies for a given page or pages.
Anchors in URLs _setAllowAnchor()

Set this method to use the # sign as a query string delimiter in campaign tracking URLs.

This method allows you to get reporting data for campaign tracking parameters even if your site doesn't support query parameters. For example, if your webserver hosts static content for speed in page delivery, you will not be able to retrieve campaign tracking data using the conventional query strings. In this case, you can use the _setAllowAnchor() method in your tracking code, which will reconfigure campaign tracking to retrieve campaign URL strings after the anchor.

Set Campaign Timeout _setCampaignCookieTimeout() By default, campaigns are tracked for 6 months, so that you can determine over a 6-month period if visitors to your site convert based on a specific campaign. However, you can use this method to adjust the tracking life span for your campaigns.
Campaign Overrides _setCampNOKey By default, the most recent ad impression is the campaign that is credited in your conversion tracking. If you prefer to associate the first-most impressions to a conversion, use this method.

Custom Campaign Tracking

Google Analytics automatically collects your Google Ads data if you have linked your Google Ads account to your Analytics account. If you have non-Google Ads keyword links using other advertising sources, or if you want to track user clicks to your site from email campaigns or similar sources, you can create custom campaigns using the URL Builder Tool. The tables below describe the ga.js methods you can use to create customize campaign tracking behavior for your site. See the Campaign Tracking Reference for specific examples for these methods.

Variable Type Method Description
Campaign Name _setCampNameKey This variable is used to define the name of your campaign, which appears in the Analytics reports on the top-level campaign report.
Campaign Source _setCampSourceKey The source variable is typically used to define where the campaign is originating from, such as a website name or a company. For all campaigns, or for a particular campaign, this appears as Source under the Segment pull-down in the Analytics Reports.
Campaign Medium _setCampMediumKey Typically used to define the type of the campaign, such as a banner ad, email campaign, or click ad. For all campaigns, or for a particular campaign, this appears as Keyword under the Segment pull-down in the Analytics Reports.
Campaign Term _setCampTermKey Defines the keyword terms for that ad. For all campaigns, or for a particular campaign, this appears as Keyword under the Segment pull-down in the Analytics Reports.
Campaign Content _setCampContentKey Typically used to set the content description for that campaign ad. For all campaigns, or for a particular campaign, this appears as Ad Content under the Segment pull-down in the Analytics Reports.