0

I am working with Sitecore 10 and CDP. I have created a custom web template in Sitecore CDP and trying to track all user Activity. Previously it worked fine, but now it doesn't track the user activity. I have added the below script in to the layout file and track the Identity event from custom Template API.

Can anyone help me to solve this?

<script type="text/javascript">
  // Define the Boxever queue
  var _boxeverq = _boxeverq || [];
  _boxeverq.push(function () {
      var viewEvent = {
          "browser_id": Boxever.getID(),
          "channel": "WEB",
          "type": "VIEW",
          "language": "EN",
          "currency": "EUR",
          "page": window.location.pathname,
          "pos": "xxx"
      };

      //Add UTM params
      viewEvent = Boxever.addUTMParams(viewEvent);
      // Invoke event create
      // (<event msg>, <callback function>, <format>)
      Boxever.eventCreate(viewEvent, function (data) { }, 'json');
  });
  
  // Define the Boxever settings
  var _boxever_settings = {
      client_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx', //Replace with your client key display in screen shot
      target: 'https://api.boxever.com/v1.2', // Replace with your API target endpoint specific to your data center region
      cookie_domain: 'xxx.dev.local', //Replace with the top level cookie domain of the website that is being integrated
      pointOfSale: "xxxx", //Replace with newly created POS
  };

  // Import the Boxever library asynchronously
  (function () {
      var s = document.createElement('script');
      s.type = 'text/javascript';
      s.async = true;
      s.src = 'https://d1mj578wat5n4o.cloudfront.net/boxever-1.4.8.min.js';
      var x = document.getElementsByTagName('script')[0];
      x.parentNode.insertBefore(s, x);
  })();
</script>

I am getting following error in console enter image description here

2
  • Your script works fine for me (even on localhost) with my own client_key. So, I just can guess that problem is with your client_key.
    – x3mxray
    Dec 28, 2021 at 14:55
  • Can you check all variables are passed as expected? Primarily check clientkey, cookie domain, and pointofSale matches. You can dynamically also pick POS = _boxever_settings.pointOfSale and browser_id: Boxever.getID(). You can also refer to working copy from CDP Events JS
    – Madhav
    Feb 1, 2022 at 18:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.