- OurPcGeek
- Posts
- How to Append Visitor IDs to a URL Using JavaScript
How to Append Visitor IDs to a URL Using JavaScript
Adobe Analytics Cross Domain Tracking,step-by-step guide on how to append Marketing Cloud Visitor IDs to a URL using JavaScript
In this blog post, we will guide you on how to append Marketing Cloud Visitor IDs (MCID) to a destination URL using JavaScript. This technique can be useful when you want to pass user data between pages or applications seamlessly.
Step 1: Open the Desired URL
Start by navigating to the following URL in your browser:
Step 2: Open Your Browser Console
To run the JavaScript code, you need to open the browser’s developer tools and go to the Console tab. Here, you can execute the necessary script.
Step 3: Run the Code in the Console
Next, paste the following code into your browser’s console to get the Visitor object and append the visitor ID to the destination URL:
var visitor = Visitor.getInstance("F5237FF9@AdobeOrg");
destinationURLWithVisitorIDs = visitor.appendVisitorIDsTo("https://xyz.newloanapp.com/apply");
window.location = destinationURLWithVisitorIDs;
This code works as follows:
Visitor.getInstance("F5237FF9@AdobeOrg")
initializes the Adobe Visitor object with your unique Marketing Cloud Org ID.visitor.appendVisitorIDsTo("https://xyz.newloanapp.com/apply")
appends the visitor ID to the target URL.window.location = destinationURLWithVisitorIDs;
redirects the browser to the new URL with the appended Marketing Cloud Visitor ID.
Step 4: Check If the Visitor ID Matches
To ensure that the appended visitor ID is correctly passed to the destination page, you can check the ID on both the source and destination URLs. Use the following code on both the https://xyz.a.com/
and https://xyz.newloanapp.com
pages:
_satellite.getVisitorId().getMarketingCloudVisitorID();
This will retrieve the Marketing Cloud Visitor ID for both pages. If the IDs match, then the appending process has been successful.
Conclusion
By using JavaScript to append the Marketing Cloud Visitor ID, you can pass crucial visitor data between domains, ensuring that the tracking and personalization features work across multiple web pages. This method is a simple yet effective way to maintain session data and create a seamless experience for your users.
Reply