Skip to content

Commit f7e2fd7

Browse files
feat: support setting of mixpanel page event names
1 parent b2ab2bb commit f7e2fd7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/analytics-plugin-mixpanel/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const analytics = Analytics({
111111
| Option | description |
112112
|:---------------------------|:-----------|
113113
| `token` <br/>**required** - string| The mixpanel token associated to a mixpanel project |
114+
| `pageEvent` <br/>_optional_ - string| Event name to use for page() events (default to page path) |
114115
| `customScriptSrc` <br/>_optional_ - string| Load mixpanel script from custom source |
115116

116117

packages/analytics-plugin-mixpanel/src/browser.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @link https://getanalytics.io/plugins/mixpanel/
44
* @param {object} pluginConfig - Plugin settings
55
* @param {string} pluginConfig.token - The mixpanel token associated to a mixpanel project
6+
* @param {string} [pluginConfig.pageEvent] - Event name to use for page() events (default to page path)
67
* @param {string} [pluginConfig.customScriptSrc] - Load mixpanel script from custom source
78
* @return {object} Analytics plugin
89
* @example
@@ -141,7 +142,7 @@ function mixpanelPlugin(pluginConfig = {}) {
141142
* the path as tracked event and search parameters as properties
142143
*/
143144
page: ({ payload }) => {
144-
mixpanel.track(payload.properties.path, payload.properties);
145+
mixpanel.track(pluginConfig.pageEvent || payload.properties.path, payload.properties);
145146
},
146147
/* https://developer.mixpanel.com/docs/javascript-full-api-reference#mixpaneltrack */
147148
track: ({ payload }) => {

0 commit comments

Comments
 (0)