Question

Mixpanel Not Receiving Some Page Load Events From Segment

  • 17 June 2020
  • 1 reply
  • 48 views

I set up Segment to track page loads and specific events on my website with Mixpanel as one of my destinations. I’ve set up page load tracking with the code snippet suggested in the Segment docs (i am using react so this is in my index.js file and is loaded every time a page is loaded):

    <script>
      !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t,e){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.1.0";
      analytics.load("xxxxx");
      analytics.page();
      }}();
    </script>

 

My page load events are being received by Mixpanel but they don’t come through with a name property and therefore Mixpanel doesn’t know what page is being loaded. Can anyone suggest a way to dynamically include a name property in the event sent to Mixpanel for each page? Thank you!


1 reply

problem solved

Reply