Digital Marketing

Tracking Conversions Across Subdomains with AdStage

AdStage Team 1 minute read

conversion-tracking-code When you started your online business, you probably only had one subdomain for your website, like 'www'. Since then, your site may have grown to have multiple subdomains like 'store.yoursite.com' and 'login.yoursite.com'. In this post, we’ll help you setup your AdStage conversion tracking to support multiple subdomains.

The Issue with Subdomains

It can be tricky to track conversions across different subdomains. Maybe a customer first visits your site from an ad that links to 'www.yoursite.com', but then converts on 'store.yoursite.com' by buying a product and visiting your thank you page. But because those two parts of your site are on different subdomains, and web browsers don't normally share cookies between subdomains, this prevents us from successfully tracking the conversion.

Fortunately, a small change to the AdStage tracking code will track conversions across all your subdomains seamlessly.

Modifying Your Tracking Code for Subdomains

First, you’ll need to already have the AdStage conversion tracking code on your site (if not, you can learn more about it here ). Next, you’ll need to make a very simple change to your code to include a new command (highlighted in yellow) to set the cookie domain.

Adstage conversion tracking code

The part we added was:

_as('set', 'cookieDomain', '.yoursite.com');

This addition tells the customer's web browser store the AdStage cookies on your top level domain rather than on the subdomain. This allows the cookies to be accessed across all your subdomains.

Note: You must include the dot at the beginning of your domain in this command, because without it, your cookies won't be shared across subdomains. Also, the 'cookieDomain' command must be called before the 'pageview' command, or the cookies will not be stored on the specified domain.

Seamless Cross-Subdomain Tracking

Now you can track conversions even as your customers move between subdomains. They can land on 'www.yourdomain.com' and convert on 'login.yourdomain.com', and the AdStage conversion tracker will correctly attribute the conversion to the ad that generated it!

If you have any other questions about how to set up AdStage conversion tracking, ask in the comments below.

AdStage Team