Web Analytics: Understanding CDN and Custom Domain Impacts

Public Original Author Jessica January 1, 2024

Using cloud storage and serving it through a custom domain (like assets.domain.com) can indeed affect how visitor data is captured, particularly in relation to tracking scripts.

Here’s a breakdown of the potential impacts:

1.  Caching and CDN Interactions:

  • If your assets (like images, JavaScript files, CSS, etc.) are stored on AWS S3, Google Cloud, Cloudflare R2 and or Azure Blob and are served through a Content Delivery Network (CDN), the CDN might cache these assets. Cached assets are served more quickly to the user, but this can affect how tracking scripts are loaded and executed.
  •  If a tracking script is cached, it may not execute the tracking code each time the page is loaded, which can lead to underreporting in tools like Google Analytics or Jetpack.

2. Custom Domain Configuration:

  • Using a custom domain (like assets.domain.com) for your assets can help with branding and might improve load times due to browser connection limits per domain.
  • However, if the tracking scripts are hosted on this domain, it’s crucial to ensure they are not cached or that they are configured to still trigger tracking events properly even when served from the cache.

3. Cross-Domain Tracking Issues:

  •  If your main site is on one domain and your assets (including tracking scripts) are on another, this can sometimes lead to issues with cross-domain tracking.
  • Browsers with strict privacy settings or users with certain ad blockers might block tracking requests that appear to come from a different domain than the main site.

4.  Tracking Script Execution:

  • Ensure that your tracking scripts are loaded and executed properly on each page load. This might require configuring your CDN settings or adjusting how scripts are embedded in your site.

5. S3 and CDN Performance Impacts:

  • While using cloud storage and a CDN (content delivery network) can improve website load times, make sure this setup does not delay the loading of critical tracking scripts. Slow loading of these scripts can result in missed tracking events, especially if users navigate away from the page quickly.

To address these issues:

  • Review CDN and Caching Settings: Check your CDN’s configuration to ensure that it properly handles tracking scripts, allowing them to execute on each page load.
  • Test Cross-Domain Tracking: If you are using different domains for your site and assets, test to ensure that tracking scripts are not being blocked or mishandled.
  • Optimize Script Loading: Make sure that your tracking scripts are loaded in an optimized manner, so they don’t delay page rendering but also don’t miss capturing initial user interactions.
  • Monitor and Adjust: Regularly monitor your analytics data for any signs of discrepancies and adjust your setup as needed.

If you’re not sure how to configure these aspects, it might be helpful to consult with a web developer or a specialist in web analytics to ensure that your tracking setup is optimized for your specific configuration.