This guide will cover how to implement the Analytics.js SDK for MetaRouter and begin sending events into your MetaRouter cluster from your website. This is the easiest MetaRouter install and can generally be completed in minutes, assuming you have already created your Data Infrastructure.
Once the snippet is placed on your website within the
<head> tag, you will be ready to trigger events from your website:
Note that there are two edits you need to make to the above snippet:
- Your CDN URL, which is where the analytics.js file the snippet calls to is located. You will need to determine your preferred DNS settings prior to setting the CDN URL and adding the snippet. Please see this guide for more information.
- Your writeKey, which will be determined as a part of your MetaRouter cluster setup.
Default Page Events
The snippet above includes the
analytics.page() function, which will automatically trigger Page calls. You can remove this function from the snippet if you do not want to trigger Page calls on every webpage loaded on your website. We recommend leaving this function in the snippet in most cases.
Considerations for Self-Hosting CDN files
We recommend hosting the Analytics.js file within your own CDN in order to receive the maximum 1st Party benefits from our platform.
You will be provided a custom-built version of this SDK that is GZIP compressed. To maintain this compression, which minimizes the page load time, you will need to set the following Metadata on the SDK within your CDN if it does not do so automatically.
On the Upload window, add the following Metadata
With the following events, you can track almost any kind of action being taken and consistently identify the users on your website. Check out each event type below to learn more about when to trigger them and what to include with each event.
The Analytics.js library places identifiers in the form of first-party cookies on the browser that are persisted between user sessions. The library will always create the
ajs_anonymous_id cookie if that cookie is not already present, and will create the
Updated 6 months ago