mixpanel


Mixpanel cookie not being set


TL;DR; Mixpanel doesn't set its cookie provoking the distinct_id to change constantly
I have 3 mixpanel projects: local/staging/pro. In local mixpanel tracking is working just fine, but in staging even with the code being identical (except the mixpanel token), events are being sent properly, but always with a disting_id changed. So, I see every event in mixpanel as if it were coming from a different device?!
I checked it and the problem is probably coming from the fact that mixpanel is not setting its cookie at all in my browsers.
The source code for staging looks like this:
<head>
...
<script type="text/javascript" async="" src="//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js"></script>
before
<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>
and finally I track
<script>
mixpanel.track('Visit');
</script>
If it is your staging site, you might be using a top level domain that don't allow cross subdomain cookies (think heroku, aws, etc), for example, yoursubdomain.herokuapp.com. You can either:
Map your staging yousubdomain.topleveldomain.com to staging.yourdomain.com using a CNAME record in your DNS settings
or
Manually enable cookies in mixpanel.init
mixpanel.init(PROJECT_TOKEN, {cross_subdomain_cookie : false});
Here is the mixpanel doc that explains: https://mixpanel.com/help/questions/articles/mixpanel-and-herokuappcom-subdomains-and-other-common-top-level-domains
And here is the list of top level urls that breaks cookies: https://publicsuffix.org/list/effective_tld_names.dat

Related Links

Mixpanel Android - consecutive timeEvent requests scenario
Mixpanel: event color in activity feed
how to see value of distinct_id in Mixpanel
Is there a wildcard character for the Mixpanel API “export” method “event” parameter?
how to do mixpanel.people.increment in Segment
how to get total number of mixpanel events via API
creating a profile with mixpanel to track users not working
How to deal with users who signed up before Mixpanel alias was set up?
Mixpanel — delete user with all past data
Google Mobile Analytics Event Tracking: Multiple properties to describe an event in google analytics
Mixpanel how to check if user exist?
Can I use data attributes as a selectors for Mixpanel mixpanel.track_links?
Where do I set user profile in my code for registered users and the users who are going to register in future using Mixpanel?
What does Mixpanel's $signup event do?
Mixpanel: distinct_id being set but events not recording against profile
How to export Mixpanel events, segmented by time?

Categories

HOME
cocoapods
openshift
spring-data
memory
gaming
vagrant
bots
add-on
elk-stack
onvif
scheduler
log4j2
solution
getopenfilename
bootstrap-switch
pushdown-automaton
async-await
exec-maven-plugin
deepfreeze
error-logging
stackexchange.redis
firemonkey-style
router
bonita
google-play-developer-api
es6-modules
toad
snap-framework
bootstrap-sass
ms-solver-foundation
code-rally
nanogallery
jacoco-maven-plugin
oauth2-playground
grails3.2.0
ejml
distributed-caching
return-type
tinyioc
supertest
cordova-ios
email-forwarding
lvalue
1010
mpmovieplayercontroller
business-rules
bpms
zynq
oci
fragmentstatepageradapter
rails-engines
swiffy
ioctl
webgrind
deeplink
variable-length-array
mousehover
extend
apple
webproject
shoes
scala-macros
prism-4
innerhtml
htmltidy
fiware-bosun
sunos
flurry-analytics
global-scope
lmax
loginview
redpitaya
air-native-extension
jchartfx
mute
yii-booster
indesign-server
statechart
dynamic-rdlc-generation
cyrillic
jsplitpane
user-forums
system-requirements
getproperty
telerik-ajax
wcf-callbacks
directshow.net
simile
resharper-5.1
uninstaller
3270
external-sorting
tacit-programming
rtti
objectinstantiation
watchpoint
html-generation

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App