0

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>
1
  • the parameter in setuserinfo should always be "email" even if you supply a value that is not an emailaddress
    – EazyE
    Commented Nov 25, 2019 at 19:26

1 Answer 1

0

Normally, when using GTM, I start by creating the appropriate triggers and variables in GTM - benefiting from having these set globally. E.g. when identifying the visitor, I would (in my case) create MC - Hashed Subscriber ID:

enter image description here

Also have a conditional event, firing the tag only when this value is set:

enter image description here

And referencing the MC - Hashed Subscriber ID in collect code:

_etmc.push(["setUserInfo", {"email": "{{MC - Hashed Subscriber ID}}"}]);

Also, I would heavily advise against having any PII populated in the URL for identifying your visitor. So using email address is a big no-go. Use subscriber key, or even better: a hashed version of it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .