Skip to main content
Cross-Domain Tracking with Cometly

Learn how to use Cometly's cross-domain tracking setup to ensure consistent user tracking and accurate attribution across your sites.

Updated over a week ago

Start Here 👋

In order to track users accurately as they navigate between your marketing site and your app, Cometly uses a unique identifier called the comet_token. This token ensures that user interactions across domains are tied together, enabling accurate attribution of traffic and conversions.

Issue:

When users move between different domains (e.g., from your marketing site to your app), the comet_token may change, which disrupts tracking continuity. This can affect your ability to accurately link user behavior between the marketing site and the app.

Solution:

To resolve this, you need to install a domain override script on your marketing site. This script ensures that when users click a button or link that directs them to your app (e.g., app.cometly.com), the comet_token from the marketing site is automatically linked to the token on the app domain. As a result, the same comet_token is used for the entire user session, preserving tracking across domains.

Important: This override script should only be placed on the marketing site. Do not install it on the app domain (app.cometly.com) or the domain to which the override is pointing.

Single Domain Example

If you're only tracking between your marketing site and a single app domain (e.g., app.cometly.com), use the following script. Be sure to place it above the Cometly base code in the <head> section:

Important: Make sure to update the code below with your own app domain and Cometly base code before using it—do not copy and paste directly from this example.

<script>
window.cometlyDomainOverrides = ['app.cometly.com'];
</script>

Full Example:

<script>
window.cometlyDomainOverrides = ['app.cometly.com'];
</script>

<script src="https://t.cometlytrack.com/e?uid=EXAMPLE-TRACKING-CODE-s"></script>

Multiple Domain Example (Optional):

If you are tracking multiple domains (e.g., app.cometly.com, academy.cometly.com, go.cometly.com), use the following script:

Important: Make sure to update the code below with your own app domain and Cometly base code before using it—do not copy and paste directly from this example.

<script>
window.cometlyDomainOverrides = ['app.cometly.com', 'academy.cometly.com', 'go.cometly.com'];
</script>

Full Example for Multiple Domains:

<script>
window.cometlyDomainOverrides = ['app.cometly.com', 'academy.cometly.com', 'go.cometly.com'];
</script>

<script src="https://t.cometlytrack.com/e?uid=EXAMPLE-TRACKING-CODE-s"></script>

How It Works:

Once the script is installed, whenever a user clicks a button or link on your marketing site that takes them to one of the app domains (e.g., app.cometly.com), the comet_token from the marketing site will be automatically passed to that app domain. This ensures the same token is used for tracking on all linked domains.

For example:

  • A user lands on cometly.com.

  • They click a link that directs them to app.cometly.com.

  • The comet_token from cometly.com will be passed to app.cometly.com, so both domains share the same token.

Verifying that Cross-Domain Tracking Works

To ensure cross-domain tracking is working correctly, follow these steps:

Step 1: Check the Link for the comet_token Override

  1. On your marketing site, hover over a button or link that directs to the domain in the cometlyDomainOverrides script (e.g., app.cometly.com).

  2. Check the URL it points to. You should see a parameter in the URL that looks like this:

    cometly_token_override=<comet_token>

This confirms that the comet_token from the marketing site is being passed to the app domain.

Step 2: Verify the comet_token in Developer Tools

To further verify that the comet_token is the same on both domains, you can inspect the pages using your browser's developer tools:

  1. Right-click on your marketing site and select Inspect.

  2. Go to the Network tab.

  3. In the search bar, type comet to filter the network requests.

  4. Look for Fetch/XHR events, and then click on the int event.

  5. Navigate to the Payload section. Here, you will see the comet_token included in the data.

  6. Note the last 4 digits of the comet_token.

Repeat the process after navigating to your app domain (e.g., app.cometly.com, or any additional domains if applicable) and ensure that the last 4 digits of the comet_token are the same. If the tokens match, cross-domain tracking is working correctly.

Did this answer your question?