Guess who’s back? After a short breather, the Purple Me Up newsletter is here again, packed with fresh updates just for you. Let’s dive in!
When deploying a tracking tool like Marketo’s Munchkin via tag management platforms, the core functionality remains the same: scripts are injected asynchronously into the page. However, there are practical differences to consider that can influence performance and user tracking across domains.
Let’s dive deeper into the nuances of deploying Munchkin with a tag manager, domain tracking challenges, and strategies to maintain user association across multiple domains.
The Tag Manager and Munchkin Relationship
When deploying Munchkin through a tag manager like Adobe Launch, here’s the process:
The tag manager itself is loaded asynchronously via a
<script>
injection.The tag manager then asynchronously loads and initializes the Munchkin tracking script.
This introduces an additional asynchronous loading step compared to the standard Munchkin embed, where the tracking script is embedded directly in the page without relying on a tag manager. While this added layer generally doesn’t impact most setups, it’s something to be aware of if you’re troubleshooting delayed tracking or optimizing for performance-critical applications.
Tracking Challenges Across Multiple Domains
A common challenge arises when tracking users across multiple domains. For example, if your organization owns:
www.primarysite.com
www.secondarysite.net
www.tertiarysite.org
By default, Munchkin cookies are domain-specific and cannot be shared across these private domains. This means:
A user may be anonymous on one domain but known on another, even if they’ve interacted with both.
This separation leads to fragmented data and impacts your ability to provide a seamless, personalized experience across domains.
Strategies for Cross-Domain Tracking
1. Unifying Paths Under a Single Domain
Consolidate your tracking into a single domain by differentiating paths rather than using multiple private domains. For example:
Instead of:
www.brandA.com
www.brandB.com
Use:
www.mybrand.com/brandA
www.mybrand.com/brandB
This approach allows the same Munchkin cookie to be used, preserving user data across all paths.
2. Passing Cookie Values via Query Strings
You can maintain user association for setups requiring multiple domains by including the Munchkin cookie value in query strings when navigating between domains. Here's an example workflow:
Generate the Cookie Value in Domain A
var munchkinCookie = document.cookie .split('; ') .find(row => row.startsWith('_mkto_trk=')) ?.split('=')[1];
Append the Cookie Value to Links to Domain B
if (munchkinCookie) { var links = document.querySelectorAll('a'); links.forEach(link => { var url = new URL(link.href); if (url.hostname === 'www.secondarysite.net') { url.searchParams.append('mkto_cookie', munchkinCookie); link.href = url.toString(); } }); }
Consume the Cookie Value in Domain B
On the destination site, extract themkto_cookie
value from the query string and set it as the Munchkin cookie:var params = new URLSearchParams(window.location.search); var mktoCookie = params.get('mkto_cookie'); if (mktoCookie) { document.cookie = `_mkto_trk=${mktoCookie}; path=/; domain=.secondarysite.net`; }
3. Cookie Migration (Browser-Specific)
In browsers that support third-party cookies (e.g., not Safari), you can use iframes to migrate cookies between domains without requiring user navigation. Here’s how:
Domain A: Embed an invisible iframe pointing to a dedicated endpoint on Domain B.
Domain B: The iframe sets the cookie using the
document.cookie
API.Example Setup: In Domain A:
<iframe src="https://www.secondarysite.net/set-cookie?value=_mkto_trk_value" style="display:none;"></iframe>
In Domain B (server-side endpoint
/set-cookie
):app.get('/set-cookie', (req, res) => { const value = req.query.value; res.cookie('_mkto_trk', value, { domain: '.secondarysite.net', path: '/' }); res.send('<script>window.close();</script>'); });
Best Practices for Maintaining Data Integrity
Browser privacy settings (especially in Safari and Firefox) may block third-party cookies or cross-site tracking. Always validate your implementation across major browsers.
Minimize delays in script loading by ensuring the tag manager and Munchkin script are hosted on reliable CDNs.
Use browser developer tools and network logs to confirm that cookies are being set and transferred as expected.
That’s all for now! Have a great week, and we’ll see you next Thursday!
Happy Marketo’ing! 💜
So great to see the newsletter back again Sire! 👏🏆 As insightful and informative as ever 🌟 Thanks so much for sharing your knowledge and wisdom with us 😇