Skip to content
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

Unloading Plugins based on Path #430

Open
markojak opened this issue Mar 29, 2024 · 1 comment
Open

Unloading Plugins based on Path #430

markojak opened this issue Mar 29, 2024 · 1 comment

Comments

@markojak
Copy link

Hi All,

Does anyone know if this wrapper allows for the ability to unload and then load a separate Segment.com writeKey based on the router path? I can't find any documentation on unloading plugins

What we're trying to do is exclude Segment.com from loading marketing (google ads, Bing etc.) on App paths.
What makes this hard to do with NextJS is that it will persist the script across marketing/app pages and you cannot do a analytics.load("") update call in analytics.js because segment re-writes these functions (I think)

@DavidWells
Copy link
Owner

You can conditionally enable/disable stuff https://getanalytics.io/conditional-loading/#enabling--disabling-plugins

routerListenerThingie((route) => {
  if (route === 'foo') {
    analytics.plugins.disable(['segment])
  }
})

Or perhaps you can initialize another analytics instance without those plugins and call that instances .page, .track etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants