没有设置Mixpanel cookie

时间:2015-12-12 10:52:47

标签: mixpanel

TL; DR; Mixpanel没有设置其cookie来激发distinct_id不断变化

我有3个mixpanel项目:local / staging / pro。在本地mixpanel跟踪工作正常,但即使代码相同(除了mixpanel令牌),事件正在正确发送,但总是更改disting_id。那么,我看到mixpanel中的每个事件都好像来自不同的设备?!

我检查了一下,问题可能来自mixpanel在我的浏览器中根本没有设置cookie的事实。

分段的源代码如下所示:

    JFrame theFrame = new JFrame();
    theFrame.setSize(300,300);
    theFrame.setResizable(false);
    theFrame.setVisible(true);

之前

<head>
    ...
    <script type="text/javascript" async="" src="//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js"></script>

最后我跟踪

<script>
  (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
  for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
  mixpanel.init("xxxxxx3ecxxx68a2ff74xxxx", {debug:true});
</script>

1 个答案:

答案 0 :(得分:3)

如果是您的暂存网站,您可能正在使用不允许跨子域Cookie的顶级域名(例如heroku,aws等),例如yoursubdomain.herokuapp.com。你可以:

  1. 使用DNS设置中的CNAME记录将您的暂存yousubdomain.topleveldomain.com映射到staging.yourdomain.com
    1. 在mixpanel.init中手动启用Cookie

      mixpanel.init(PROJECT_TOKEN,{cross_subdomain_cookie:false});

    2. 以下是mixpanel文档:https://mixpanel.com/help/questions/articles/mixpanel-and-herokuappcom-subdomains-and-other-common-top-level-domains

      以下是打破Cookie的顶级网址列表:https://publicsuffix.org/list/effective_tld_names.dat

相关问题