Marketing Attribution 102
Everything you ever wanted to know about Amplitude’s Browser SDK 2.0
About our author: Jim Kultgen
Jim Kultgen is a Product Strategist and Solutions Architect at Amplitude. He was a former power user at Cars.com and joined Amplitude with one goal in mind - make the product better! Jim talks to users all of the time, can be found in the Amplitude community, and is always pushing the limits on what our platform can and should do.
The two most exciting reasons for me to join Amplitude after a career as an analyst were to:
- Help build the tools organizations need to understand and improve their customers' experiences.
- Create the content that I always needed to have to utilize analytics platforms.
This post represents the second category and goes deep on the powerful out-of-the-box features for managing marketing attribution concepts within Amplitude’s Browser SDK 2.0.
Prerequisite concepts
User vs Event Properties
Event properties in Amplitude are attributes of your user’s events. These properties do not extend beyond the specific event.
User properties in Amplitude do not need to be sent with every event. Once a user property is set its value persists and Amplitude applies it to all subsequent events until the value changes.
The attribution properties managed within browser SDK 2.0 leverage user properties. Here’s why:
When a user enters your application from bing.com via organic search, you probably want to continue to give credit to bing.com until another marketing tactic is introduced or until the session ends. By relying on user properties that value can be set and then persisted until replaced rather than having to be stored in a client and sent with each event.
Leveraging user properties in lieu of event properties for channel-classifier properties enables last-touch-esque attribution throughout the platform in lieu of the need to solely rely on attribution models within a data table.
Identify API
The Identify API is an Amplitude feature to update user properties for a specific user without sending an event. Attribution leverages three of Amplitude’s user property operators.
$setOnce
Set the value of the property only if the value hasn’t already been set.
With $setOnce the application does not need to maintain awareness of a user’s history. Amplitude’s servers will evaluate if there is an existing value for a given user property. If there is, the new value will not overwrite the original value.
$set
Sets the value of the property.
$unset
Removes the value of the property.
$unset allows one to discontinue the persistence of a user property when it is no longer relevant.
Scenario:
A user visits your site from facebook.com and the SDK detects that via the referring domain. Later the same user visits the site with an email campaign that is identified by a utm_medium=email, and without a referring domain value.
By using the $unset operator facebook.com will not continue to receive credit for the subsequent email campaign.
Marketing attributes
By default Amplitude’s Browser SDK 2.0 manages attribution concepts for 19 marketing identifiers. For each of these 19 properties there are two user properties, which is addressed later in this post.
- UTM Parameters
- UTM Parameters can be added to urls by anyone, but are generally a combination of marketer logic and platform derived values. The first parameter is added with a ‘?’ any subsequent parameters with an ‘&’.
- example: https://amplitude.com/get-started?utm_source=google-ads&utm_medium=cpc&utm_campaign=Search_AMER_Brand&utm_content=707830940836&utm_term=amplitude&gad_source=1
- Referrers
- Referrer is the term used to describe an optional field that is transmitted via the HTTP header when a web page is requested from a server. Loosely it represents the page that routed a user to the current page, if applicable.
- This is generally collected via the JavaScript variable document.referrer in the browser.
- Click identifiers
- Click identifiers are added to urls by the marketing platform. The first parameter is added with a ‘?’ any subsequent parameters with an ‘&’.
- example: https://amplitude.com/get-started?utm_source=google-ads&gclid=Cj0KCQiAu8W6BhC-ARIsACEQoDBO-yDVCQstX56lQvCgVl6RnzfI9vZloqxVWHUykumq44YyHxwtCk8aAgm1EALw_wcB
External referrers
Marketing attribution generally refers to the external tactics that motivate users to reach an application. To evaluate which referrers are considered internal and should be ignored for attribution Amplitude accepts inputs to the ‘config.autocapture.attribution.excludeReferrers’ parameter. By default the SDK will update this parameter to include the top level domain with cookie storage enabled.
In addition to the default value, . Two common use cases:
- An organization uses a third party payment processing site.
- A subdomain like checkout.stripe.com should be listed in excludeReferrers to prevent marketing credit being assigned to the processor.
- An organization uses social sign-in features from google, apple, or facebook.
- Subdomains like accounts.google.com or accounts.youtube.com may be listed in excludeReferrers to ensure they don't receive attribution credit.
- Tip: Including a custom value overrides the default settings. If you add any custom values also include your owned domain/subdomains in the exclusion list.
When an excluded referrer is present Amplitude skips the evaluation of utm parameters and click identifiers.
Example scenario:
A promotions marketer at Amplitude appends ?utm_medium=amplitude&utm_campaign=home_hero_march_2025 to a link on a homepage hero directing to amplitude.com/guides-and-surveys. The utm attributes will not be evaluated because the referrer, amplitude.com, is in the excludeReferrers list. This prevents internal and external campaigns from being inadvertently mixed in one property, which can lead to external attribution being lost.
Cookies
Browser SDK attribution relies on the ability to set and read from two cookies; the ‘user session’ cookie ‘AMP_{first_ten_digits_API_KEY}’ and the ‘marketing campaign’ cookie ‘AMP_MKTG_{first_ten_digits_API_KEY}’.
These cookies allow the SDK to evaluate session context and to evaluate if marketing attributes were updated.
Note: The ‘user session’ cookie does not expire after a session. This cookie can be thought of as the ‘identity’ cookie as it maintains the device_id.
Attribution types
initial_[marketing_attribute]
The user_properties prefixed with ‘initial_’ represent the user's first-touch marketing tactic.
These values persist beyond Amplitude’s 365 day maximum lookback window for first-touch attribution.
The SDK uses the $setOnce operator for these properties. While you may see initial_[marketing_attribute] values more than once in the $identify events the original value will not be overwritten on Amplitude’s servers.
Values that are not available receive a string value of “EMPTY”. This is to ensure that if the value for a property wasn’t initially present it doesn’t receive credit at a later time.
[marketing_attribute]
The version of the user properties without the ‘initial_’ prefix can be used for last-touch and multi-touch attribution.
These properties are maintained in relationship to one another. If a new utm_medium is introduced and a referring domain is not available the utm_medium will be updated with the $set operator and the referring_domain will be updated with the $unset operator.
Evaluation process
- When initialized the SDK checks if marketing attribution is enabled. By default it is enabled and may be disabled via
- If disabled, attribution is not updated.
- The logic evaluates if the referrer is in the exclusion list.
- If the referrer is in the excluded list, attribution is not updated.
- The logic evaluates if the event is “direct” and mid-session. “direct” in this sense means without a referrer, without utm parameters, and without click identifiers.
- If mid-session and direct, attribution is not updated.
- This session-aware step in the process is possible by referencing the ‘AMP_{first_ten_digits_API_KEY}’ cookie.
- The logic evaluates if the current marketing attributes are the same as those stored in the ‘AMP_MKTG_{first_ten_digits_API_KEY}’ cookie.
- If the values are the same, attribution is not updated.
- If the values are different:
- intial_[marketing_attribute] any available attributes are $setOnce with their value. Any unavailable attributes are $setOnce as “EMPTY:
- [marketing_attribute] any available attributes are $set and any unavailable attributes are $unset
Optional Features
Two additional optional features are available in the .
- config.autocapture.attribution.resetSessionOnNewCampaign
- Configures Amplitude to start a new session if any marketing attributes changed. By default this is set to false. Changing this to true allows organizations to evaluate attribution similarly to Google’s Universal Analytics, where the introduction of a new campaign instantiated a new session.
- config.autocapture.attribution.initialEmptyValue
- Allows you to set the value that is used to represent an attribute not being available in the initial_[marketing_attribute] properties. By default this value is “EMPTY”.
Other ingest methods
One of Amplitude’s greatest strengths is that we are an open ecosystem. Customers can ingest data through CDI’s, directly through warehouses, or via API.
While the content above focuses on the Browser SDK 2.0 it illuminates core concepts that organizations need to consider when ingesting data for attribution use cases.
- For many organizations attribution requires session-awareness, specifically the ability to update attribution differently at the start of a session versus mid-session.
- A separate property should exist for only those referrers you consider external to your platform. In addition to your owned domain(s) this should include any partner applications that a user encounters during their journey with you, like payment processors and social logins.
- Attributes must be updated in relation to each other to prevent over-persistence.
Next Steps
In the next post in this series we will evaluate how to leverage these users properties within Amplitude’s channel classifier.
Join the community!
Connect with Jim and other Amplitude users. The Cohort Community exists to help people become better analysts. We focus on actionable programs, sharing best practices, and connecting our members with peers and mentors who share in the same struggles.