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

Add information to documentation #32

Open
quimeparle opened this issue Dec 11, 2019 · 1 comment
Open

Add information to documentation #32

quimeparle opened this issue Dec 11, 2019 · 1 comment

Comments

@quimeparle
Copy link

By default the views tracker sends the name of the route when it is integrated with vue-router. The doc mentions the possibility of customizing the name of the view but not how to indicate the path of the route. Based on your code I used the usePathAnalytics parameter to fix this problem. It's the best pratice ? thanks for your help

@ScreamZ
Copy link
Owner

ScreamZ commented Dec 11, 2019

Hello,

You have two options:

  • Adding a meta: {analytics: "someValue"} to your route config.
  • use usePathAnalytics to use route name.
  // If specified : the system will use the path instead of the route name.
    Vue.analytics.trackView(to.meta.analytics || to.name, trackPage)
    const viewName = to.meta.usePathAnalytics ? to.path : to.name

    // Dispatch vue event using meta analytics value if defined otherwise fallback to route name/path.
    Vue.analytics.trackView(to.meta.analytics || viewName, trackPage)

Here is the internal code matching that :)

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