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

[gatsby-plugin-google-gtag] Disable default pageview tracking #9842

Merged
merged 3 commits into from
Nov 15, 2018

Conversation

valse
Copy link
Contributor

@valse valse commented Nov 9, 2018

The default behavior of the config snippet is to send a pageview automatically; this is in contrast with the exclude option and the plugin tracks, on page load, even the excluded pages.

This PR solve also the double pageview hits on page load too: the first is made by the default behavior and the second one by the onRouteUpdate event.

@valse valse changed the title Disable default pageview tracking [gatsby-plugin-google-gtag] Disable default pageview tracking Nov 9, 2018
Copy link
Contributor Author

@valse valse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the GA doc page url exaplaining the issue and sanitized the not required object too, thanks.

@pieh pieh merged commit 1e8f665 into master Nov 15, 2018
@pieh pieh deleted the valse-patch-1 branch November 15, 2018 13:53
@pieh
Copy link
Contributor

pieh commented Nov 15, 2018

published gatsby-plugin-google-gtag@1.0.6

gpetrioli pushed a commit to gpetrioli/gatsby that referenced this pull request Jan 22, 2019
…tsbyjs#9842)

The default behavior of the `config` snippet is to send a pageview automatically; this is in contrast with the `exclude` option and the plugin tracks, on page load, even the excluded pages.

This PR solve also the double pageview hits on page load too: the first is made by the default behavior and the second one by the `onRouteUpdate` event.
@ardalis
Copy link

ardalis commented Jun 5, 2020

How do I override this so it actually sends page views?
My realtime analytics has dropped to 0 since migrating my blog to gatsby from wordpress and using this plugin.

I tried the obvious (in gatsby-config.js):

        gtagConfig: {
          anonymize_ip: false,
          cookie_expires: 0,
          send_page_view: true
        },

but it seems to be ignored. Help?

@valse
Copy link
Contributor Author

valse commented Jun 5, 2020

Hi you don't need to override it because it's a bugfix: do you add your tracking id on the trackingIds array option?

Are you checking it on production? The tracking is disabled on development mode.

Do you have disabled any ad blocks: sometimes you forget to disable them and you don't understand why the analytics doesn't work 😅

@ardalis
Copy link

ardalis commented Jun 5, 2020

I ended up using the google tag manager and got it working just fine.

https://www.youtube.com/watch?v=__PctBcNZ-c
This video helped.

Good point about ad blockers, though. :)

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

Successfully merging this pull request may close these issues.

3 participants