Skip to content

Commit

Permalink
feat: support setting of mixpanel page event names
Browse files Browse the repository at this point in the history
  • Loading branch information
laurence-hudson-mindfoundry committed Jun 25, 2021
1 parent b2ab2bb commit e13ec89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/analytics-plugin-mixpanel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const analytics = Analytics({
| Option | description |
|:---------------------------|:-----------|
| `token` <br/>**required** - string| The mixpanel token associated to a mixpanel project |
| `pageEvent` <br/>_optional_ - string| Event name to use for page() events (default to page path) |
| `customScriptSrc` <br/>_optional_ - string| Load mixpanel script from custom source |


Expand Down
3 changes: 2 additions & 1 deletion packages/analytics-plugin-mixpanel/src/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @link https://getanalytics.io/plugins/mixpanel/
* @param {object} pluginConfig - Plugin settings
* @param {string} pluginConfig.token - The mixpanel token associated to a mixpanel project
* @param {string} [pluginConfig.pageEvent] - Event name to use for page() events (default to page path)
* @param {string} [pluginConfig.customScriptSrc] - Load mixpanel script from custom source
* @return {object} Analytics plugin
* @example
Expand Down Expand Up @@ -141,7 +142,7 @@ function mixpanelPlugin(pluginConfig = {}) {
* the path as tracked event and search parameters as properties
*/
page: ({ payload }) => {
mixpanel.track(payload.properties.path, payload.properties);
mixpanel.track(config.pageEvent || payload.properties.path, payload.properties);
},
/* https://developer.mixpanel.com/docs/javascript-full-api-reference#mixpaneltrack */
track: ({ payload }) => {
Expand Down

0 comments on commit e13ec89

Please sign in to comment.