How will you write a page load global event triggered with value passed from CMS kapa.ai
To track a page load global event triggered with a value passed from a CMS using Mixpanel, you can use the JavaScript SDK. Here's how you can set it up:1. First, make sure you have the Mixpanel JavaScript SDK initialized on your page. You can do this by adding the Mixpanel snippet to your page, as described in the Quickstart guide.2. To automatically track page views, you can enable the track_pageview
option when initializing Mixpanel:LBKSmixpanel.init('YOUR_PROJECT_TOKEN', { track_pageview: true });LBKS
This will automatically track a "Page View" event every time a new page is loaded, as mentioned in the FAQ section.3. To pass a custom value from your CMS, you can add it as a property to the page view event. You can do this by using the track_pageview
method and passing an object with your custom properties::LBKSLBKS```LBKSmixpanel.track_pageview({
"custom_cms_value":: "Your CMS value here"
});LBKSLBKS4. If you want to use a different event name or have more control over the tracking, you can use the `track` method instead:LBKSLBKS
mixpanel.track("Page Loaded", {
"page_name": document.title,
"custom_cms_value": "Your CMS value here"
});```Remember to replace "Your CMS value here" with the actual value you want to pass from your CMS.By following these steps, you'll be able to track page load events globally and include custom values from your CMS as properties of the event.For more detailed information on tracking page views and setting up event properties, you can refer to the Mixpanel JavaScript SDK documentation.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.