-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two problems with using Mixpanel #370
Comments
I have the same problem about wrong naming of the "page_view" event. |
@TimToshiro I think your second problem comes from the missing A temporary fix could be : analytics.page({
url: pageUrl,
$email: "[email protected]"
}); You can find the list of mixpanel reserved properties here : https://docs.mixpanel.com/docs/tracking/how-tos/user-profiles#reserved-user-properties |
I noticed the same problem with page views on mixpanel as well. Sounds like the email property has to be changed to $email and that transformation should happen at the plugin I also noticed some related PRs that are old but haven't been pulled. Is this library still under active maintance? |
Update - solved. I took a look at the mixpanel plugin and there's a way to override the page event: So this is how i configured my analytics.tsx import type { ReactNode } from "react";
import React, { useEffect } from "react";
import Analytics from "analytics";
import { AnalyticsProvider } from "use-analytics";
import mixpanelPlugin from "@analytics/mixpanel";
import { useRouter } from "next/router";
import { env } from "src/env/client.mjs"; // Make sure this module is typed
const analyticsInstance = Analytics({
app: "fastmonitor",
plugins: [
mixpanelPlugin({
token: env.NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN as string, // Type casting as string, assuming it's always defined
track_pageview: true,
pageEvent: "page_view",
}),
],
debug: env.NEXT_PUBLIC_HOST.includes("localhost"),
});
export default function AnalyticsHOC({ children }: { children: ReactNode }) {
const { pathname, query, asPath } = useRouter();
useEffect(() => {
analyticsInstance.page({
path: pathname,
query: query as { [key: string]: string },
host: window.location.origin,
});
}, [pathname, query, asPath]);
return (
<AnalyticsProvider instance={analyticsInstance}>
{children}
</AnalyticsProvider>
);
} And this is how it's rendering in mixpanel: and for reference, in my _app.tsx (im using pages router) return (
<>
<SessionProvider session={session}>
<AnalyticsHOC>
<Component {...pageProps} />
</AnalyticsHOC>
</SessionProvider>
</>
);
}; |
Hello. I have two problems related to work with Mixpanel.
The first one:
When I use function call at page opening - then event comes out incorrectly and has extremely inconvenient name among events on Mixpanel site itself.
const analytics = Analytics({
app: 'Test',
plugins: [
mixpanelPlugin({
token: 'test',
}),
googleAnalytics({
measurementIds: ['G-TEST'],
})
]
})
analytics.page({
url: pageUrl,
});
Second:
When I add information to a user, I see the name as a built-in parameter, but the email address is passed as custom and initially I don't see it in the table in the list of users. But I can see it inside properties of the user if I open full information. I don't have this problem with the name.
analytics.identify('testID', {
email: email,
name: name,
})
The text was updated successfully, but these errors were encountered: