Passing "external id" to mixpanel


(Leah Kramer) #1

Hello all. We started using mixpanel recently on our main site (Wordpress) and it’s working nicely. We’d like to add some mixpanel javascript calls to our associated Discourse site as well.

For adding the mixpanel javascript we’re doing this via Discourse Admin / Customize / CSS/HTML and putting javascript before the closing head tag.

This works great for simple mixpanel calls like this:

<script type="text/javascript">
mixpanel.track("Page View", {
    "page name" : document.title,
    "url" : window.location.pathname,
    "page type" : "Forum",
    "custom referrer tracking": document.referrer
});
</script>

But we also need to be able to pull the current user’s “external id” (that’s the id of the user in Wordpress which is stored in Discourse via the sso code) and pass that to mixpanel. So, the code for this would look something like:

<script type="text/javascript">
grab the external id via the api and store it in a variable $external_id
mixpanel.identify($external_id);
</script>

How can we do this? Thanks!


(Jeff Atwood) #2

Sorry for the late reply. Did you get this resolved?