Advanced Topics

Web Attribution Tracking

While Amplitude’s TypeScript Browser SDK does not collect web attribution data by default, setting it up is simple. The SDK can automatically collect this information if certain attribution configuration options are enabled.

Amplitude supports automatically tracking the following through the SDK configuration options:

  • The 5 standard UTM parameters from the user's browser cookie or URL parameters by using includeUtm.
  • The referring URL and domain from includeReferrer.
  • Google Click Identifier from URL parameters through includeGclid.
  • Facebook Click Identifier from URL parameters through includeFbclid.

Tracking UTM Parameters

UTM parameters stand for Urchin Traffic Monitor parameters and are useful for analyzing the effectiveness of different ad campaigns and referring sites. Note that UTM parameters are case sensitive so they will turn out to be different values if the capitalization varies.

There are five different standard UTM parameters:

  • utm_source: This identifies which website sent the traffic (e.g. Google, Facebook).
  • utm_medium: This identifies what type of link was used (e.g. banner, button, email).
  • utm_campaign: This identifies a specific campaign used (e.g. summer_sale).
  • utm_term: This identifies paid search terms used (e.g. product+analytics).
  • utm_content: This identifies what brought the user to the site and is commonly used for A/B testing (e.g. bannerlink, textlink).

Here is an example URL:

https://www.amplitude.com/?utm_source=newsletter&utm_campaign=product_analytics_playbook&utm_medium=email&utm_term=product%20analytics&utm_content=bannerlink

Enabling UTM Parameters Tracking

In Amplitude, once you set the includeUtm option to true, the SDK will automatically pull UTM parameters from the referring URL and include them as user properties on all of the relevant events:

  • includeGclid: Gclid (Google Click Identifier) is a globally unique tracking parameter used by Google. If utilized, Google will append a unique parameter (e.g. "?gclid=734fsdf3") to URLs at runtime. By setting this to true, the SDK will capture initial_glid and gclid as user properties.

  • includeFbclid: Fbclid (Facebook Click Identifier) is a globally unique tracking parameter used by Facebook. If utilized, Facebook will append a unique parameter (e.g. "?fbclid=392foih3") to URLs at runtime. By setting this to true, the SDK will capture initial_fblid and fbclid as user properties.

  • includeUtm: If true, finds the standard UTM parameters from either the URL or the browser cookie and sets them as user properties. This will set utm_source, utm_medium, utm_campaign, utm_term, and utm_content as well as initial_utm_source, initial_utm_medium, initial_utm_campaign, initial_utm_term, and initial_utm_content as user properties for the user.

Those UTM parameters will be set as user properties which will persist for all of the user's events going forward. However, initial UTM parameters are captured only once for each user via a setOnce operation.

Tracking Referrers

If you want to track how users are getting to your website, then all you need to do is track the referrer (the referring site).

Here are the fields Amplitude supports tracking automatically:

Enabling Referrers Tracking

Once you set the includeReferrer option to true, Amplitude will capture the referrer and referring_domain for each session and set them as user properties on all of the relevant events:

  • includeReferrer: If true, captures the referrer and referring_domain for each session as user properties as well as the initial_referrerandinitial_referring_domainuser properties once for each user. The referrer is the entire URL while thereferring_domain` is only the domain name from where the user came from.

Initial referring information is captured only once for each user via a setOnce operation.

First-Touch Attribution

Amplitude can capture the initial UTM parameters and referrer information for each user. The first-touch attribution values are set when a user's non-null UTM parameters are seen for the first time. The following user properties are set once:

  • initial_utm_source
  • initial_utm_medium
  • initial_utm_campaign
  • initial_utm_term
  • initial_utm_content
  • initial_referrer
  • initial_referring_domain
  • initial_gclid
  • initial_fbclid

This is done by setting the TypeScript Browser SDK configuration options includeReferrer, includeUtm, includeGclid and includeFbclid to true.

Note: Initial attribution information for users can change if there are merged users.

Last-Touch Attribution

In addition to first-touch attribution, Amplitude will capture where a user came from for each of their sessions. This is accomplished by setting the following user properties:

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_term
  • utm_content
  • referrer
  • referring_domain
  • gclid
  • fbclid

This is done by setting the SDK configuration options includeReferrer, includeUtm, includeGclid and includeFbclid to true.


Did this page help you?