Passing "external id" to mixpanel

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

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

How can we do this? Thanks!

1 Like

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