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 πŸ‘‹

To accurately track users as they navigate between your marketing site and your app, Cometly uses a unique identifier called the comet_token. This token links user interactions across different domains, ensuring precise attribution of traffic and conversions.

Problem:
When users navigate between different domains (e.g., from your marketing website to your application), the comet_token may change. This disrupts tracking continuity, making it difficult to accurately connect user behavior across the marketing site and the app.
​

Solution:

Implement our Cross-Domain Tracking feature, either through automatic configuration or manual setup. This ensures that when a user clicks a button or link leading to another domain, the comet_token is seamlessly passed along. As a result, the same comet_token persists throughout the entire user session, maintaining uninterrupted tracking across all domains.

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.

You have two options for setting up Cross-Domain Tracking with Cometly:


Automatic Cross-Domain Tracking Setup

If you prefer a straightforward setup, follow these steps to enable automatic cross-domain tracking:

  1. Install the Cometly Pixel:

    • Add the Cometly Pixel to the <head> of every marketing page (including blogs and academies) and if you are setting up tracking for your SaaS company, only add the pixel to the login and registration pages of your app.

  2. Add & Verify Domains:

    • Navigate to the Install Pixel setup page in your Cometly dashboard.

    • Add all your domains where the pixel is installed.

    • Complete the verification process to ensure accurate tracking across these domains.

  3. Toggle On Cross Domain Tracking:

    • In the Install Pixel setup area, toggle on the Cross Domain Tracking feature.

    • Your verified domains will automatically utilize the comet_token for tracking.

What This Does:

  • Automatic Tracking: The comet_token is automatically passed between your verified domains.

  • Seamless User Journeys: Effortlessly track user interactions across multiple websites, providing a complete and unified view of their journey.

Why It Matters:
Enabling this feature ensures that all user activities are accurately tracked, regardless of the domain they interact with. This comprehensive tracking helps you understand user behavior better and optimize their experience across all your platforms.


Manual Cross-Domain Tracking Setup

If you encounter issues with the automatic Cross Domain Tracking feature or prefer manual configuration, follow these steps to set it up manually:
​

Understanding the Issue

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

Solution: Domain Override Script

To maintain tracking continuity, you need to install a domain override script on your marketing site. This script ensures that when users click a button or link directing 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. This means the same comet_token is used throughout the user session, preserving cross-domain tracking.


Important:

  • Only install the override script on your marketing site.

  • Do not install the script on the app domain (app.cometly.com) or any other domains.

Single Domain Example

If you're tracking between your marketing site and a single app domain (e.g., app.cometly.com), use the following script.
​
​Place it above the Cometly base code in the <head> section of your Marketing Site ONLY. Do not place the cometlyDomainOverrides script on your app/other domain.

Important:

  • Update the script with your own app domain and Cometly tracking code.

  • Do not copy and paste directly from this example without customization.

<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:

Place it above the Cometly base code in the <head> section of your Marketing Site ONLY. Do not place the cometlyDomainOverrides script on your app/other domain.

Important:

  • Update the script with your own app domain and Cometly tracking code.

  • Do not copy and paste directly from this example without customization.

<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>


Verifying Cross-Domain Tracking

Ensure that your cross-domain tracking setup is functioning correctly by following these verification steps:

Step 1: Check the Link for the cometly_token_override

  1. On Your Marketing Site:

    • Hover over a button or link that directs to a domain specified in the cometlyDomainOverrides script (e.g., app.cometly.com).

  2. Inspect the URL:

    • Ensure the URL includes a parameter like:

      rubyCopy code?cometly_token_override=ABC123
    • This confirms that the comet_token from the marketing site is being passed to the app domain.

Step 2: Verify the cometly_token in Developer Tools

  1. On the Marketing Site:

    • Right-click and select Inspect.

    • Navigate to the Network tab.

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

    • Look for Fetch/XHR events and click on the relevant event.

    • Go to the Payload section and locate the comet_token.

    • Note the last 4 digits of the comet_token.

  2. On the App Domain:

    • Repeat the above steps on app.cometly.com.

    • Ensure that the last 4 digits of the comet_token match those from the marketing site.

Successful Verification:

  • The comet_token is identical across both domains, confirming that cross-domain tracking is working correctly.

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?