Deploying Your Tracking File
Overview
To deploy MetaRouter's Analytics.js (AJS) tracking library or Standalone Sync Injector on your website, the tracking file must be hosted somewhere your website can load it. MetaRouter gives you two ways to do this:
| Method | Best for |
|---|---|
| Auto-Deploy to Cluster | Teams that want a streamlined, automated process with minimal manual file handling |
| Manual Deployment | Teams that require strict control over any JavaScript deployed to their website |
Both methods support first-party hosting, which improves tracking efficacy in environments where ad blockers are in use.
Note for existing customers: The MetaRouter-hosted CDN option has been deprecated. MetaRouter no longer maintains a CDN on behalf of customers, and all customers are now required to host their own tracking files.
If you do not have access to the Auto-Deploy to Cluster option and would like to learn more about it, please contact your MetaRouter Customer Success Manager.
Key Concepts
Before getting started, it helps to understand two URLs you'll work with throughout setup:
Cluster File Endpoint The URL where MetaRouter hosts your built tracking file on your cluster. This is the source of truth for your file — your CDN origin or CI/CD job should pull from here.
https://YOUR_CLUSTER_URL/v1/pipelines/YOUR_WRITEKEY/file
Distribution URL The URL that visitors' browsers use to load the tracking file. This is the URL you enter in the MetaRouter File Builder, and it should point to wherever you are serving the file from (your CDN or your own infrastructure).
These two URLs serve different purposes: the Cluster File Endpoint is for retrieving the file during deployment; the Distribution URL is for serving the file to end users.
Auto-Deploy to Cluster
With auto-deploy, MetaRouter hosts your built tracking file at the Cluster File Endpoint as soon as you upload it. From there, you integrate with the endpoint using one of two approaches:
- CDN origin pull — Your CDN pulls from the cluster endpoint and serves the file to end users.
- CI/CD pipeline — An automated job pulls the file from the cluster endpoint, allowing you to test and approve it before deployment (in most cases, to a CDN).
Step 1 — Build and Upload Your File
- In the MetaRouter UI, navigate to your web source and open the File Builder.
- Configure your tracking file.
- Select your File location – choose Auto-deploy to Cluster.
- Enter your File Hosting URL (the URL browsers will use to load the file) and Ingestion Website URL (your Cluster's event ingestion endpoint).
- Configure file settings, consent settings, and Sync Injector Identity Syncs.
- Click Save & Build File.
- On the File Summary page, click Upload File to Cluster.
Your file is now available at the Cluster File Endpoint.
Step 2 — Integrate with the Cluster Endpoint
Option A: CDN Origin Pull
Point your CDN's origin at the Cluster File Endpoint. Your CDN will pull and cache the file, serving it to end users with minimal latency.
- In your CDN, create a new distribution and set the Cluster File Endpoint as the origin.
- Configure caching rules to suit your expected update frequency.
- Confirm that HTTPS is enabled for your distribution.
- Enter your CDN's domain as the Distribution URL in the MetaRouter File Builder.
Host header behavior: Some CDNs forward the client's
Hostheader to the origin by default rather than the origin's hostname. If your CDN offers a setting to use the origin hostname as theHostheader, enable it to ensure requests reach the cluster correctly.When you update your file: Re-upload in the MetaRouter UI, then invalidate your CDN cache to ensure the latest version is served. Users with the file cached in their browser may need to clear their cache as well.
Option B: CI/CD Pipeline Integration
Pull the tracking file into your CI/CD workflow so you can test and approve changes before they reach production.
- Configure a job in your CI/CD pipeline to fetch the file from the Cluster File Endpoint:
https://YOUR_CLUSTER_URL/v1/pipelines/YOUR_WRITEKEY/file - Add any testing or approval steps required by your team.
- Deploy the approved file to your server or CDN.
- Ensure the Distribution URL in the File Builder matches where you are serving the file from.
Keeping the file up to date: Your pipeline job needs to be triggered each time you rebuild the file in MetaRouter. Consider using a webhook (below) to automate this.
Option C: Serve File Directly from Cluster (Not Recommended)
It is possible to set the Cluster File Endpoint as your Distribution URL, so client browsers fetch the tracking file directly from the cluster. This is not recommended for production use.
The MetaRouter cluster is not a CDN and is not optimized to serve static files at scale. Using this option in production will result in increased file load latency and added stress on cluster infrastructure, which can affect the reliability of your data pipeline.
This option may be useful for low-volume testing scenarios where a CDN or other file hosting strategy has not yet been configured.
Setup:
- Set your File Hosting URL in the File Builder to the Cluster File Endpoint (available on the File Summary page):
https://YOUR_CLUSTER_URL/v1/pipelines/YOUR_WRITEKEY/file - Build and upload your file as described in Step 1.
Using a different hosting strategy? Options A, B, and C represent common hosting approaches, but they are not exhaustive. If your team has a different hosting strategy in mind, that may work fine — just make sure to inform your Customer Success Manager so they can ensure your setup is fully supported.
Step 3 (Optional) – Configure Your Deployment Webhook
Details coming soon!
Manual Deployment
Manual deployment gives your team full control over the file before it is deployed. No file is hosted on the cluster — instead, you download the file from MetaRouter and manage hosting entirely within your own infrastructure.
Best for: Organizations that require review and approval of any JavaScript file before it reaches their website.
Steps
- In the MetaRouter UI, navigate to your web source and open the File Builder.
- Configure your tracking file and click Save & Build File.
- On the File Summary page, download the built file.
- Host the file on your server or CDN.
- Ensure the File Hosting URL in the File Builder matches the URL where you are hosting the file.
Each time you make changes to your tracking file configuration, you will need to repeat this process to download and redeploy the updated file.
Reference
| Term | Description |
|---|---|
| Cluster File Endpoint | The URL where MetaRouter hosts your built file. Use this as your CDN origin or CI/CD fetch target. Format: https://YOUR_CLUSTER_URL/v1/pipelines/YOUR_WRITEKEY/file |
| Distribution URL | The URL browsers use to load the tracking file. Enter this in the File Builder. |
| File Builder | The MetaRouter UI tool used to configure, build, and upload your tracking file. |
Updated about 14 hours ago