By default, the script already sets the dub_id cookie on a cross-domain level.

This means that if you have the script installed on your marketing site (e.g. example.com), the cookie will also be accessible when your user signs up for your app (e.g. app.example.com).

However, if you are installing the script on a subdomain (e.g. app.example.com), you will need to set the following option to make sure the cookie is accessible on the apex domain as well (e.g. example.com):

<DubAnalytics
  cookieOptions={{
    domain: ".example.com",
  }}
/>

The script also supports conversion tracking across entirely different domains.

This means that if you have the script installed on a separate domain (e.g. example.sh), you can use the outboundDomains prop to ensure that the dub_id cookie value is automatically appended to all outbound links targeting your main domain (e.g. example.com).

// install this script on both domains
<DubAnalytics
  domainsConfig={{
    outbound: ["example.com", "example.sh"],
  }}
/>

For outbound-domains support, you’ll need to use the script.outbound-domains.js variant of the script. Learn more about how script variants work.