You can place the cmSetupCookieMigration function on all pages that serve from both the originating and destination domains to migrate your cookies.
Client-managed first-party implementations set Digital Analytics cookies under the 'Cookie Domain' specified in parameter 4 of the cmSetClientID(…
) function. In cases where visitors traverse multiple second-level domains as part of a normal site visit sending data to a single Digital Analytics Client ID, it might be necessary to migrate the Digital Analytics visitor and session cookies on the prior domain to the new second-level domain to maintain visitor and session continuity in reporting. This migration is necessary to ensure complete data attribution in all reporting.
For this purpose, Digital Analytics provides the function cmSetupCookieMigration(…)
. This function is only recommended in cases where pages that are from the new second-level domain are typically visited after pages served by the original domain. Place this function call on all pages that are served from both the originating and destination domains, after the Digital Analytics library src= include and cmSetClientID(…)
call (if any), and before the cmSetProduction()
; call (if any) and any tag function calls on the page.
Parameter | Required | Description |
---|---|---|
JSFPmigration | Required | Always true |
forceVisitorOverwrite | Required | true or false. This should be true unless otherwise advised by Acoustic Support. |
domainWhitelist | Optional | Comma-delimited list of domains to which cookies should be transferred. |
domainBlacklist | Optional | Comma-delimited list of domains to which cookies will not be transferred. Cookies are migrated to all domains not in this list. |
pathWhitelist | Optional | Comma-delimited list of URL paths to which cookies will be transferred. This is necessary when a 302 redirect is forwarding the visitor directly from the original domain to the new domain. |
otherCookie | Optional | Comma-delimited list of other cookies to be migrated. (…,"cookie1,cookie2",…) |
otherCookiesExpireTimes | Optional | Object Literal defining a list of optional expiration times for specified otherCookies. (…,{"cookie1": "1234567890",…},…) |
One of the following three parameters must be specified: domainWhitelist, domainBlacklist, or pathWhitelist. In cases where both a domain list and pathWhitelist is passed, pathWhitelist is evaluated and domainWhitelist/domainBlacklist ignored.
Example #1: domainWhitelist migration from domain 1 to domain 2 (no redirect)
The visitor browses the site and products under domain #1, 'thesite.com'. After an item is carted and checkout, the visitor is linked to a page served by new domain #2, 'checkout-store.com'. The Digital Analytics Client Managed cookies should be migrated from 'thesite.com' to the new domain 'checkout-store.com' using the function cmSetupCookieMigration(…)
on all pages of domain #1 (thesite.com) and domain #2 (checkout-store.com).
<head>
<script type="text/javascript" src="//libs.coremetrics.com/eluminate.js"></script>
<script type="text/javascript">
cmSetClientID("99999999",true,"data.coremetrics.com","thesite.com");
</script>
<script type="text/javascript">
cmSetupCookieMigration(true,true,".checkout-store.com");
</script>
</head>
<body>
...
<script type="text/javascript">
cmCreatePageviewTag("Checkout: login", "checkout");
</script>
</body>
Note: Pages that are served from the new domain, checkout-store.com, should include updated calls to cmSetClientID(…)
setting Cookie Domain under the new site domain:
cmSetClientID("99999999",true,"data.coremetrics.com","checkout-store.com");
Example #2: pathWhitelist migration for 'checkout.asp' after 302 redirect.
The visitor browses the site and products under domain #1, 'thesite.com'. After carting an item and beginning checkout, the visitor is redirected (302) to a page served by new domain #2, 'checkout-store.com'. The Digital Analytics Client Managed cookies should be migrated from 'thesite.com' to the new domain 'checkout-store.com' using the function cmSetupCookieMigration(…)
on all pages of domains #1 (thesite.com) and #2. The pathWhitelist will contain "checkout.asp", uniquely identifying the URL of the first page served by the new domain after the 302 redirect.
<head>
<script type="text/javascript" src="//libs.coremetrics.com/eluminate.js"></script>
<script type="text/javascript">
cmSetClientID("99999999",true,"data.coremetrics.com","thesite.com");
</script>
<script type="text/javascript">
cmSetupCookieMigration(true,true,null,null,"checkout.asp");
</script>
</head>
<body>
...
<script type="text/javascript">
cmCreatePageviewTag("Checkout: login", "checkout");
</script>
</body>
Example #3: domainBlacklist migration + 2 other session cookies and 3 other persistent cookies with specified expiration periods in standard JavaScript millisecond date value.
<head>
<script type="text/javascript" src="//libs.coremetrics.com/eluminate.js"></script>
<script type="text/javascript">
cmSetClientID("99999999",true,"data.coremetrics.com","thesite.com");
</script>
<script type="text/javascript">
cmSetupCookieMigration(true, true, null, ".checkout-store.com", null,
"sessioncookie1,sessioncookie2,persistentcookie1,persistentcookie2,
persistentcookie3",{"persistentcookie1":1234567890,"persistentcookie2":
987654321,"persistentcookie3":2940792846});
</script>
</head>
<body>
...
<script type="text/javascript">
cmCreatePageviewTag("Checkout: login",
"checkout");
</script>
</body>
Technical details for Client-managed first-party cookies
Calling the cmSetupCookieMigration function configures the eluminate tag library to use tag migration code where possible. The domainWhitelist, domainBlacklist, and pathWhitelist parameters of cmSetupCookieMigration specify a list of domains or URL paths that are actively migrated.
When an anchor tag (<a></a>) is clicked on one of these pages, the eluminate tag library examines the anchor HREF to check whether the URL contains a domain or path specified in domainWhitelist, domainBlacklist, or pathWhitelist. If the domain or path exists in the list, the tag library appends the 'Core6ID' cookie Visitor ID and '<clientid|siteid>_clogin' cookie Session ID values as new query string parameters to the anchor/HREF destination URL.
When the destination page in the new domain2.com site is loaded, the eluminate tag library included in that page recognizes the migration parameters in the destination URL (window.location.href) and uses these values to populate any new, or overwrite any existing, Digital Analytics cookies set in domain2.com.
This ensures that cookie values set in the original domain1.com site are also used to set the same new or existing domain2.com cookies, thus maintaining visitor and session continuity across both domains.
Limitations
Client-managed 1st party cookie migration cannot function if any of these conditions exist:
- There is no <a> / anchor tag linking domain1.com to domain2.com or the link navigation is executed entirely through JavaScript, a form submit, selection list + JavaScript, or other means. Standard cookie migration is supported only for HTML Anchor links directing the visitor from domain1.com to domain2.com.
- The href= attribute of the clicked <a> anchor does not contain the required domain or path value (href attribute entirely missing, href="#", href="javascript:void(0)", etc.).
- Multiple redirects between domain1.com and domain2.com change the final URL for the destination site/domain, or otherwise, remove the migration query string parameters.
- If the standard Cookie Migration does not work due to a lack of anchors with valid <href> attribute values or other reasons listed above, it might still be possible to perform a manual implementation of cookie migration using the following procedure.
- Implement the required
cmSetupCookieMigration
calls on both the domain1.com and domain2.com site pages. - Add JavaScript to the event of the <a> anchor so that when it is clicked, the Digital Analytics CoreID6 cookie visitor ID and <clientid|siteid>_clogin session ID values are read and appended to the domain2.com destination URL using the required cm_mc_uid= (Visitor) and cm_mc_sid= (Session) migration parameters.
- Implement the required
CoreID6 cookie example
CoreID6 cookie value:57871744086114145023618&ci=5xxx0000|siteid123
Visitor ID value to be migrated is:57871744086114145023618
<clientid|siteid>_clogin cookie example
Cookie value: v=1&l=1414502361&e=1414504351070
Session ID value to be migrated:1414502361
www.domain2.com?cm_mc_uid=57871744086114145023618&cm_mc_sid_5xxx0000=1414502361
The domain2.com pages must include the required cmSetupCookieMigration
function call instructing eluminate tag library to examine window.location.href for the presence of cookie migration parameters. For other types of navigation not using HTML anchors, implement custom code to extract and append the visitor ID and session ID values to the new domain2.com destination URL.
Comments
0 comments
Article is closed for comments.