We have the following code on our website so every page is tracked in SalesForce web/mobile analytics.
We are testing with subscriber key (we really want email to be displayed in tracking)
the code below when added to the site via magento will display the subscribers "subscriberkey" in the url of a link clicked in an email, yet the subscriberkey does not display in tracking (it just shows the word "subscriberkey").
Our Salesforce partner told us The code needs to be installed in the exact same location immediately before the closing tag on every page to enable tracking.
Since we are using magento and google tag manager, our development team feels we need to tweak the theme in magento to add a custom block, and place the code there
Collect tracking code implementation
Existing code:
<script type="text/javascript">
_etmc.push(["setOrgId", "12345678"]);
var params = (new URL(document.location)).searchParams;
var SubscriberKey = params.get("SubscriberKey");
if (SubscriberKey) {
_etmc.push(["setUserInfo", {"Subscriber Key": SubscriberKey}]);
_etmc.push(["trackPageView"]);
}
Code from the documentation:
<script type="text/javascript">
var urlParams = new URLSearchParams(window.location.search);
var id = urlParams.get('visitorid');
_etmc.push(["setOrgId", "12345678"]);
if ( visitorid ) {
_etmc.push(["setUserInfo", {"email": visitorid }]);
}
_etmc.push(["trackPageView"]);
</script>