Identifying authenticated users in custom code (header)

Hi WeWeb-ers.

I’m trying to integrate a product analytics tool (https://livesession.io/), and the script by itself works great—

<!-- LiveSession.io code -->
    <script type="text/javascript">
    window['__ls_namespace'] = '__ls';
    window['__ls_script_url'] = 'https://cdn.livesession.io/track.js';
    !function(w, d, t, u, n) {
          if (n in w) {if(w.console && w.console.log) { w.console.log('LiveSession namespace conflict. Please set window["__ls_namespace"].');} return;}
          if (w[n]) return; var f = w[n] = function() { f.push ? f.push.apply(f, arguments) : f.store.push(arguments)};
          if (!w[n]) w[n] = f; f.store = []; f.v = "1.1";
  
          var ls = d.createElement(t); ls.async = true; ls.src = u;
          var s = d.getElementsByTagName(t)[0]; s.parentNode.insertBefore(ls, s);
      }(window, document, 'script', window['__ls_script_url'], window['__ls_namespace']);
  
      __ls("init", "abcdefghijklmnop", { keystrokes: false });
      __ls("newPageView");
    </script>
    <!-- END LiveSession.io code -->

However, I’m also trying to integrate it a way that identifies users, and I’m having trouble integrating the tracking code into WeWeb.

I tried using a Xano auth variable in the global website header code, but I received a build error when I tried to publish it. For example, the code I tried to publish looked something like this—

__ls("identify", { 
    email: `pluginVariables['asbcdef-485d-47be-b433-d43d771c64e1']['user']['email']`, 
})

Any idea what went wrong to cause the build to fail? Is there a different type of approach I should be doing to identify auth’d users with a 3rd party product analytics tool?

Is that your exact code? Not sure if this is what is causing a build error, but do you need the quotes around the value for email?

__ls(“identify”, {
email: pluginVariables['asbcdef-485d-47be-b433-d43d771c64e1']['user']['email'],
})

remove them:

__ls(“identify”, {
email: pluginVariables[‘asbcdef-485d-47be-b433-d43d771c64e1’][‘user’][‘email’],
})

You may need them around “email”

Thanks for chiming in, @kevinwasie. I believe that was my exact code, but I can’t recall for certain.

Not sure if this is what is causing a build error, but do you need the quotes around the value for email?

I don’t think it needs the quotes as it’s copied and pasted directly from their docs. However, I’m going to give that and some other ideas a go and report back.