Track visitors across subdomains
DataFast automatically tracks visitors across any subdomains of your main domain for maximum analytics accuracy.
Setting up subdomain tracking
- Create a website in DataFast using your root domain (e.g.,
example.com
) - Install the tracking script on all your subdomains (e.g.,
app.example.com
,blog.example.com
) - Use the same website ID and domain parameter across all installations
<script
defer
data-website-id="yourwebsiteid"
data-domain="example.com"
src="https://datafa.st/js/script.js"
></script>
Important: Always use your root domain in the data-domain
attribute, not the specific subdomain.
Benefits of cross-subdomain tracking
- Unified visitor journey: Track users as they navigate between your marketing site, app, blog, and other subdomains
- Accurate attribution: Properly attribute conversions to marketing campaigns even if users move between subdomains
- Complete analytics: Get holistic data about user behavior across your entire domain ecosystem
- Simplified reporting: View combined traffic and conversion data in a single dashboard
Common use cases
- Track user journeys from your marketing site (
example.com
) to your app (app.example.com
) - Attribute conversions to the correct marketing channel when users navigate across subdomains
- Analyze how content on your blog (
blog.example.com
) drives traffic to your main site
DataFast handles all the cross-domain cookie synchronization automatically, so you don't need to write any additional code to track users across subdomains.
Note: For more advanced proxy configurations when tracking across subdomains, see the Proxy through Next.js guide.