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

Remove query parameters #333

Open
cosbgn opened this issue Jun 10, 2021 · 3 comments
Open

Remove query parameters #333

cosbgn opened this issue Jun 10, 2021 · 3 comments

Comments

@cosbgn
Copy link

cosbgn commented Jun 10, 2021

Most social networks and ad providers add query parameters to links, things like (fclid, gclid, etc).

On analytics.js there was a way to ignore query parameters, this has been removed on GA4 and now needs to be done on site level (Something like: document.location.hostname + document.location.pathname).

Is there a way to do this automatically when page tracking is on?

@cosbgn
Copy link
Author

cosbgn commented Jun 10, 2021

Closing because if I understood correctly from another issue I just need to add: pageTrackerUseFullPath: true to the options. If I'm wrong please let me know. Thanks a lot!

@cosbgn cosbgn closed this as completed Jun 10, 2021
@cosbgn
Copy link
Author

cosbgn commented Jun 10, 2021

Reopening, this because the pageTrackerUseFullPath does the opposite, is shows query parameters. I want instead to hide them, which should be the default but it's not working for me. I'm using the plugin with nuxt like this:

import Vue from 'vue';
import VueGtag from 'vue-gtag';

export default ({ isDev, app }) => {
	if (!isDev){
		Vue.use(VueGtag, {
			config: { id: 'G-XXX' }
		},
		app.router);
	} else {
		console.log("Skipping GA in localhost")
	}
}

I think the issue might be app.router ?

I'm using V1 with vue2

@cosbgn cosbgn reopened this Jun 10, 2021
@mwargan
Copy link

mwargan commented Aug 4, 2022

@cosbgn did you ever find a solution? I'm using now V2 with Vue3 but still have this issue. Ended up disabling pageTracking and writing a custom implementation on afterEach:

const pathStayedTheSame = (to: any, from: any) => {
    if (from && Object.keys(to.query).length) {
        if (to.fullPath.split('?')[0] == from.fullPath.split('?')[0]) return true;
    }
    return false;
};
///... Other code, then in router.afterEach
if (pathStayedTheSame(to, from)) {
    return;
}

Implemented thanks to the idea from vuejs/vue-router#2072 (comment)

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