Question

Remove query strings from referrer and initial referrer

  • 31 March 2021
  • 1 reply
  • 87 views

Hi There,

I am hoping someone can help, in my application when people sign up we send them an email to confirm their email address.

In the email we include a URL that sends the user back to our site, this url contains some sensitive information that we must not record within Mixpanel, here is an example:

https://www.domain.com/auth/welcome?code=1234&email=email@email.com

I need to make sure that the code and the email in query string never comes to Mixpanel.

I am able to do that for my own “Page View” events as I have control over the value, but for the “referrer” and “initial referrer” data items these are sent automatically by Mixpanel and I don’t know how to control them.

Ideally I would solve this problem with JavaScript rather than in project settings as we create new projects on a regular basis.

If anyone has any advice on what to do that would be great.

Cheers,

Luke.


1 reply

Badge

Hi Luke,

Thanks for logging tickets with Mixpanel Support. I thought I would give a response here as well for the benefit of the community,  

Mixpanel tracks utm_* tag by default (e.g. http://www.example.com?utm_source=google&utm_campaign=ad1), which Mixpanel records as a super property by default in our web library. However, to track your custom variables you'll need to write some javascript to capture them and save them as events/properties.

This means if you are tracking the following:
https://www.domain.com/auth/welcome?code=1234&email=email@email.com
They are custom variables and will not be recorded by default. However, we do track the full URL of the webpage on which the event is triggered. -- Current URL

If you have to include the sensitive data in the URL, a way I can think of is to block the Current URL ($current_url) event property from being automatically appended to an event (mixpanel.track) on a certain URL/web page.

Our Javascript SDK does have a property_blacklist: https://developer.mixpanel.com/docs/javascript-full-api-reference#mixpanelset_config
Initializing Mixpanel with a property_blacklist will prevent the event properties (i.e. $current_url) from being automatically added to mixpanel.track calls on the page (so regardless of any event that is fired).

Your code would look like something below:

if( window.location.href.includes("URL you want to exclude") ) // $current_url

{

   mixpanel.init('your_Project_Token', {'property_blacklist': ['$current_url']});

}

else

{

   mixpanel.init('your_Project_Token');

}

 

Hope that helps!

 

Reply


Mixpanel