I need to use mixpanel Data Export API using jQuery.
According to this: How can I use mixpanel API? and according to mixpanel: https://mixpanel.com/docs/api-documentation/data-export-api#libs-js, I can use this:
$.getJSON('http://mixpanel.com/api/2.0/engage/?callback=?', {
api_key: apiKey,
expire: expire,
sig: sig
},
function (result) {
alert(result);
}
);
But as a result I get an error as result:
"unknown param: callback
for params: {'callback': 'jQuery18208090281161325954_1358248117308', 'project_id': 160130}"
I know that the url and my data is correct since when I open browser in http://mixpanel.com/api/2.0/engage/?api_key=...&expire=...&sig=... I get correct data.
What is wrong with my code?
There is nothing wrong with your code.
The
callbackparameter works for other endpoints like.../events/topand.../funnels/list, but this error is returned for this particularengageendpoint.You will have to raise this as an issue with Mixpanel, that this endpoint does not support JSONP callbacks.
Somewhat confusingly, you can post data using a different
engageendpoint, by following the instructions on this page:https://mixpanel.com/docs/people-analytics/people-http-specification-insert-data
Here is an example that works with this endpoint:
Just note that your code should work for the other endpoints in the link you provided in your question, just not for
engage.