Use HTTP Spec to send data to Mixpanel

Every week, we will release tips to help you get the most out of Mixpanel. Want to see more? Click here to see other #mpknowledgedrop articles.

Sometimes using new tools can be a bit intimidating. I know they are for me, especially if I have no idea how they work! Today we will be walking through how to send an event and user profile through an HTTP request.

Before we go through this tutorial, here are some prerequisites and systems you will need:

Here is a screenshot of the JSON I am using - I blocked out my project token :)

Next we need to copy and paste the JSON to the following base64encode website (https://www.base64encode.org/). This will give us the encoded value we will need to paste in into the engage endpoint(URL).

Now we need to attach the encoded characters to the engage endpoint(URL)

Now we can go to our Web browser, paste the engage endpoint(Put together URL)in the url box, and press enter. The screen will then return a value of 1 or 0.

If it shows 1, this means your data points were sent to Mixpanel successfully. If it is a 0, this means your request has failed.

If your post has failed, you want to repeat steps 1-4. Something to check is that the JSON is in the correct format. You can use this online checker to look at your JSON format. Also, something I noticed is that when I copy a JSON from a google doc, the double quotes format changes. So I usually go back and redo the double quote marks (“_”) and re-check the format and values. Lastly, make sure your project token is correct and other property values.

If your profile was sent successfully, you can now go into your Explore Report and see the user profile there. If you don’t see it right away, wait a few minutes to refresh! There might be a slight ingestion delay.

If you want to update user profiles, steps 1-4 are the same, the only thing you will need to be mindful of is to call "$ignore_alias": true with the JSON along with the updated values you want to send to the profile. An example on how this will look like is below

{ "$token": "PROJECT_TOKEN",

"$distinct_id": “123",

"$set": {

"$email": "testtesttest@gmail.com"

},

"$ignore_alias": true

}

Something to note: You need to make sure that the $distinct_id value matches the user you want to update. Here is a help article on how to find an existing users distinct ID in the explore report.

Send Events

Before we dive into sending events, it is important to emphasize that all events are immutable once they are sent to Mixpanel. This means that, you cannot update or alter an event that has already been sent in. That being said, you can send new events, up to 5 days old, via HTTP spec.

If you want to send in events that are more than five days old, you will need to use the import endpoint athttp://api.mixpanel.com/import/to process your request. Full details on using the import endpoint can be foundhere.

Now let’s get started!

First, we need a JSON object for the event we want to send to Mixpanel.

Now we can go to our Web browser, paste the engage endpoint(Put together URL)in the url box, and press enter. The screen will then return a value of 1 or 0.

If it shows 1, this means your data points were sent to Mixpanel successfully.If it is a 0, this means your request has failed. If your post has failed, you want to repeat steps 1-4. Something to check is that the JSON is in the correct format. You can use this online checker to look at your JSON format. Also, something I noticed is that when I copy a JSON from a google doc, the double quotes format changes. So I usually go back and redo the double quote marks (“_”) and re-check the format and values. Lastly, make sure your project token is correct and other property values as well.

If your Event was sent successfully, you can now go into your Live View and see the event there. Below I shared a screenshot of my Live View — you can see that the event was successfully sent to Mixpanel.

Congrats, you made to the end!

I hope this helped you learn how to send in user profiles and events via HTTP Spec! My walkthrough is designed to give you a simple example so you can learn and test out the process. I would highly recommend going through our HTTP Spec Dev docs, which goes into much higher detail on other things you can do with HTTP Spec!

Cookie policy

Cookie settings

We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.