Web tracking
Deploy the JavaScript tag on your websites, send the right events, and configure it server-side.
Your goal
Get the mediarithmics tag running on the pages you want to track, sending the events in your tracking plan with the identifiers you have.
Expected outcome
Events arriving from every tracked page, attributed to the right channel, carrying the identifiers you can supply - and no data collected before consent.
Prerequisites
A channel of type site for the property, and its site token. See Channels.
A consent mechanism in place before the tag fires.
How the tag is integrated
The tag tracks a visitor's navigation on a website. It is imported in a JavaScript snippet that has to be executed on every page you want to track.
The common ways to integrate it:
The snippet's code is non-blocking: it does not affect page rendering time, and it can be inserted in the <head> of the page.
Implement the snippet
The snippet is made of a technical tag containing the JavaScript that asynchronously loads the tag - which you should not edit, except to change the tag name - and the configuration, which you fill in for your context: site token, event name, event properties.
These customisations are available at the snippet level:
The tag name is the last argument of the loader, and the global object the rest of your code calls. Changing it lets you implement several tags, or use a name of your own:
To remove mediarithmics from your website entirely, contact your Account Manager to get your own domain name, then pass it in the initialisation:
You do not have to push on page load. Bind the push to an interaction instead:
Send identifiers
Use addIdentifier(type, identifier) once per identifier you can supply.
USER_ACCOUNT
{$user_account_id: string} or {$user_account_id: string, $compartment_token: string}
USER_EMAIL
{$email_hash: string} or {$email_hash: string, $email: string}
USER_AGENT
{$user_agent_id: string}
$emailis optional.$compartment_tokenis optional - if omitted, the datamart's default compartment is used.$user_agent_idis a user agent ID. Accepted agent types here are mobile advertising ID, mobile vendor ID, TV advertising ID, and custom ID.Do not add network device IDs here - they are managed from the interface. If the network device ID you need is not available, contact your Account Manager.
Several accounts can be declared by calling addIdentifier more than once, each with its own compartment token.
Send events
Default tracking
Out-of-the-box tracking generates a $page_view event - this is what the snippet does as-is:
Custom events
Refer to the predefined event names and prefer them to custom names, because the platform handles automatic processing for them.
E-commerce events
Implement the snippet at the key places, with the matching event name:
Only the first 3 items in the list should be declared.
$id is the product ID.
$price is the product price without the currency, $qty the quantity in the basket. $currency is optional - with a single catalogue the catalogue currency is used.
$id should be the same ID as the one used in your product feed. $transaction_id holds the ID of the transaction.
Add the user account ID wherever it is available - tracking is materially better with it.
Profile updates from the tag
If the user is identified, you can register updates to their profile from the snippet - typically on the profile pages of your site. Use the special event $set_user_profile_properties: its properties and values are written as key-value pairs on the UserProfile.
By default the anonymous UserProfile of the datamart's default compartment is updated, and force_replace is false. These special properties change the target:
$set_user_profile_comp_token
Optional. The compartment token of the compartment the profile should be written in. Defaults to the default compartment.
$set_user_profile_user_account_id
Optional. The user account ID under which the profile should be written. Without it, the anonymous profile is used.
Server-side configuration
Some tag behaviours are configured server-side, in the same way as with a tag manager. They are found on the corresponding channel in Navigator settings - which means you can change them without redeploying the snippet.
Device identification
Select the identifiers the tag uses automatically to identify devices:
mediarithmics first-party cookie
mediarithmics third-party cookie (vector ID)
The tag can also retrieve a user or device identifier from partners you have already integrated with: ID5, First ID, and Utiq martechpass (mobile). See Network IDs.
IAB Transparency and Consent Framework
Enable this if you want the tag to automatically take any TCF-compliant CMP on the website into account before creating third-party cookies and performing cookie matching.
Cookie matching with Google and Xandr
Select whether the tag triggers cookie matching with Google and Xandr. For other partners, check with your Account Manager.
Support of the third-party cookie (vector ID)
By default, the mediarithmics third-party cookie is not generated if the browser does not support matching with Google and Xandr. Use this setting to force its generation even when those matchings do not succeed.
The one-tag approach
A one-tag approach means tracking visitors and their behaviour with a single tracking code, rather than a different snippet per page type. It is simpler to implement and maintain, and it usually implies using an activity analyzer to process the collected data server-side.
The tag supports it by referencing variables that already exist in the browser's DOM.
The tag already collects the URL, the referrer, the user agent, and the time, so these do not need to be provided:
Collect the relevant properties from the data layer:
All properties are stored in the tc_vars variable:
AMP pages
AMP pages are tracked with the amp-analytics module, which must be present in the page environment.
site_token
String
The token of the website. Required.
event_name
String
The name of the event. Optional, defaults to $page_view.
any custom property
String
Custom properties go in the extraUrlParams object.
Verify
The channel's event count over the last 7 days is non-zero in Settings > Datamart > Channels.
The
JS_TAGstep shows events in ingestion monitoring. See Monitor data ingestion.A real user's activities carry the identifiers and properties your plan specifies. See Explore a user profile.
Nothing is collected before consent is given.
Troubleshooting
No events at all
The site token is wrong, the snippet is not executing, or consent is never granted.
Events arrive but no user is identified
addIdentifier received invalid arguments - it fails silently - or the compartment token does not exist.
Page views disappear
$page_view events are dropped at session close by design.
A property is missing from queries
It is not indexed in the schema, or an event rule or analyzer changed it.
A device identifier never appears
The corresponding registry or channel-level device identification is not enabled.
Related pages
Last updated
Was this helpful?