Skip to content

Commit

Permalink
fix(v2): GTM, send page_view events on navigate (#3243)
Browse files Browse the repository at this point in the history
* fix: update pageviews for Google Tag Manager

* fix prettier issues

Co-authored-by: govardhan <govardhan.s@mobinius.com>
  • Loading branch information
govardhan-srinivas and govardhan authored Aug 12, 2020
1 parent 97faf7e commit 98ccb37
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/docusaurus-plugin-google-gtag/src/gtag.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export default (function () {
// Always refer to the variable on window in-case it gets overridden elsewhere.
window.gtag('config', trackingID, {
page_path: location.pathname,
page_title: document.title,
});
window.gtag('event', 'page_view', {
page_title: document.title,
page_location: location.href,
page_path: location.pathname,
});
},
};
Expand Down

0 comments on commit 98ccb37

Please sign in to comment.