The Javascript SDK provides a few different methods to send event data to your project. Calling any of the event tracking methods below will generate an event payload, then trigger a request to the /track API endpoint to ingest the event into your project.
All events sent from the JavaScript library will be sent over HTTPS.
Page view tracking is turned off by default. Page view events can be added automatically on every page load by enabling the track_pageview
config option when creating the Mixpanel object.
// Track when the path changes, ignoring any query string or hash changes
mixpanel.init('YOUR_PROJECT_TOKEN', {
track_pageview: "url-with-path"
});
// Track when the path or query string change, ignoring hash changes
mixpanel.init('YOUR_PROJECT_TOKEN', {
track_pageview: "url-with-path-and-query-string"
});
// Track any URL changes in the path, query string, or hash
mixpanel.init('YOUR_PROJECT_TOKEN', {
track_pageview: "full-url"
});