Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Apr 19, 2024 @ 02:22
    Abby (CMS Editor/Manager for Blueberry Markets)
    0

    Mixpanel code in Umbraco 11 - how to check if working

    Hello here.

    I've added a Mixpanel code (similar to the Hubspot code I posted a while ago), and it looks like it's not firing on the live site.

        </script><script type="text/javascript">
      (function(c,a){if(!a.__SV){var b=window;try{var d,m,j,k=b.location,f=k.hash;d=function(a,b){return(m=a.match(RegExp(b+"=([^&]*)")))?m[1]:null};f&&d(f,"state")&&(j=JSON.parse(decodeURIComponent(d(f,"state"))),"mpeditor"===j.action&&(b.sessionStorage.setItem("_mpcehash",f)));var l,h;window.mixpanel=a;a._i=[];a.init=function(b,d,g){function c(b,i){var a=i.split(".");2==a.length&&(b=b[a[0]],i=a[1]);b[i]=function(){b.push([i].concat(Array.prototype.slice.call(arguments,
    0)))}}var e=a;"undefined"!==typeof g?e=a[g]=[]:g="mixpanel";e.people=e.people||[];e.toString=function(b){var a="mixpanel";"mixpanel"!==g&&(a+="."+g);b||(a+=" (stub)");return a};e.people.toString=function(){return e.toString(1)+".people (stub)"};l="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
    for(h=0;h<l.length;h++)c(e,l[h]);a._i.push([b,d,g])};a.init(b);b=e}d="undefined"!==typeof c?c:b.jQuery||window.jQuery;d&&d(b,a);a.snippetVersion=1.0;var i,g;g=window;g=b;g.attachEvent?g.attachEvent("onload",i):g.addEventListener("load",i,!1)}})(document,window.mixpanel||[]);
    mixpanel.init("TOKEN_CODE");
    </script>
    

    enter image description here

    It seems not appearing in DevTools using Chrome.

    Thank you

  • Marc Goodson 2149 posts 14354 karma points MVP 8x c-trib
    Apr 19, 2024 @ 19:13
    Marc Goodson
    0

    Hi Abby

    It will depend a little on how your Umbraco site is implemented...and how the script property is written out in the template... But

    My immediate thought was your script is starting with a closing tag

    </script>

    And I thought that can't be right must be a cut and paste issue, scripts should always start

    <script>

    But then I saw the help text in your screenshot that says

    DO Not include the script tag elements (script) - just the inner script...

    ... So maybe you just need to remove all the

    </script> and <script> tags from the box and just start with the (function bit?

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft