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

fix(v2): GTM, send page_view events on navigate #3243

Merged
merged 2 commits into from
Aug 12, 2020

Conversation

govardhan-srinivas
Copy link
Contributor

Closes #3047

Motivation

Was following Facebook open-source immersion program, recently did my PR to the Material UI repo, So thought to give a try.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Followed the Google Analytics document while implementing pageviews.

Demo site with this change: https://govardhan-srinivas.github.io/docusaurus-blog-mode/
Screenshot of pageviews in google analytics
image

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 8, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Aug 8, 2020

Deploy preview for docusaurus-2 ready!

Built with commit 29b622a

https://deploy-preview-3243--docusaurus-2.netlify.app

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Thanks

LGTM, but prettier failure

@govardhan-srinivas
Copy link
Contributor Author

While I was debugging few minutes back I found out that adding the parameter 'send_page_view' to existing config would also send page views to Google analytics.
Here I have created a gist for it.

@slorber @yangshun Please let me know how we should proceed?

@slorber
Copy link
Collaborator

slorber commented Aug 11, 2020

@govardhan-srinivas I don't know gtag unfortunately and don't even have an account.

What do you feel is the right solution, and have you actually tested it live on a real Docusaurus site and GTM account to ensure it works?

Also if you hesitate between solutions, please help me help you by linking to the relevant parts of the docs

@govardhan-srinivas
Copy link
Contributor Author

@slorber I was refering this link, I find 2 ways of capturing pageviews:

  1. Automatically captured with this snippet
  2. Manually capture it when there is a location change[Existing implementation in the pull request].

Both does the same functionality but I feel second one has more advantage over the first, As we can set manual break points when to trigger the page view event.
Eg: when we have SPA and infinite scrolling content[like facebook posts], then we can add manual trigger event considering each section as a virtual page within.

If we agree on above thing, we can merge this PR.

@slorber
Copy link
Collaborator

slorber commented Aug 12, 2020

Thanks, this solution looks fine

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Aug 12, 2020
@slorber slorber changed the title fix: update pageviews for Google Tag Manager fix(v2): update pageviews for Google Tag Manager Aug 12, 2020
@slorber slorber merged commit 98ccb37 into facebook:master Aug 12, 2020
@slorber slorber changed the title fix(v2): update pageviews for Google Tag Manager fix(v2): GTM, send page_view events on navigate Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Tag Manager - Doesn't recognize blog page change
4 participants