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

Proposal for some useful functionalities. #377

Open
phlegx opened this issue Sep 20, 2021 · 0 comments
Open

Proposal for some useful functionalities. #377

phlegx opened this issue Sep 20, 2021 · 0 comments

Comments

@phlegx
Copy link

phlegx commented Sep 20, 2021

Hi @MatteoGabriele! Congratulation for this nice Vue package. Here some useful functionalities that can be added to vue-gtag to get better control over the plugin.

  1. Add method to check if gtag DOM elements (script and link) are already included (with or without bootstrap() method).
  2. Alternative: with method bootstrap() check before if gtag DOM elements (script and link) are already included to avoid duplicate gtag DOM elements. If already included don't add DOM elements.
  3. Add method to remove (unload, inverse of bootstrap()) the gtag DOM elements.
  4. Add possibility to exclude tracking on single route or all sub-routes in the tree by setting a meta value in routes definitions.
  5. Split pageTrackerExcludedRoutes to two separate settings pageTrackerExcludedRoutePaths and pageTrackerExcludedRouteNames to speed up the code.

Here an example for proposal 4. and 5.:

const isRouteExcluded = (route) => {
  const { pageTrackerExcludedRoutePaths: paths, pageTrackerExcludedRouteNames: names } = getOptions();
  return paths.includes(route.path) || names.includes(route.name) || 
         route.meta.gtagExcludeRoute || route.matched.some((record) => record.meta.gtagExcludeRouteTree);
};

if (isRouteExcluded(to)) {
  return;
}
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

1 participant