Using URL Query Strings to Pass Information

You can use URL query strings to pass information to make custom links for referral programs and email unsubscribe pages.

Email platforms don’t allow dynamic coding, such as JavaScript. However, you can use Mixpanel to pass incredibly useful information to your project.

Using URL Parameters for a Referral Program

Referral programs are a very effective method to advertise your company.  

You can leverage Mixpanel’s dynamically populating people properties for messages to create custom links for a referral or invitation program. For example, you can create a link to a sign up page where users can share with their friends. In the code for the body of the email, you can set the username as a query string parameter for the link.

< a href="www.example.com/signuppage.html?inviter={{$username}}">share this link</a> 

In this example message,  the resulting link for a profile with the username “patdavis” would be www.example.com/signuppage.html?inviter=patdavis.

Make sure the signup page (www.example.com/signuppage.html can handle this parameter. Include the getQueryParam function code above in the header tags of the webpage.

Next call this function and grab the “inviter” value in the URL and set it as a super property to automatically make it a property of every event the user triggers.

Below is an example of the code to place between the body>code</body tags in the signup page.

var inviter = getQueryParam("inviter");
mixpanel.register({
   "Inviter": inviter,
});
mixpanel.track("Page Loaded", {"Page Viewed": "Sign Up"});

Now with “inviter” set as a super property, you’ll be able to view any event, such as registration page view, and see if it came from a referral program.

Creating a Custom Unsubscribe Page

Using URL parameters allows you to pass information from sites you don’t own, such as creating a custom unsubscribe page for email messages sent with Mixpanel People.

Currently if a user clicks the unsubscribe link from your Mixpanel email message, they land on a Mixpanel hosted unsubscribe page. This page runs a script that sets an “$unsubscribed” people property with a “True” value to prevent the user from receiving any more messages from that project.

You can use URL parameters to redirect users to your own domain so you can re-engage with customers one last time or style the page to match your site’s design.

To do so, set your users’ distinct_id as a property of their profile or a user id aliased to the distinct_id. For example, you could set the user email address or username as the distinct_id of the profile.

Use dynamically populating values in a message to create an unsubscribe link:

< a href="www.example.com/unsubscribe.html?id={{$email}}">Unsubscribe</a>

On the unsubscribe page (www.example.com/unsubscribe.html) use the function to grab the “id” value. However, instead of setting this value as a super property, use it as the distinct_id of a people set to set the “$unsubscribed=True” property to that specific user’s profile. Here is an example:

var inviter = getQueryParam("inviter");
mixpanel.register({
    "Inviter": inviter,
});
mixpanel.track("Page Loaded", {"Page Viewed": "Sign Up"});

Now with “inviter” set as a super property, you’ll be able to view any event, such as registration page view, and see if it came from a referral program.

Is this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.