File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
packages/smooth-plugin-google-analytics/src Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-env browser */
2
2
export function onRouteUpdate ( { location } ) {
3
3
// Don't track while developing.
4
- if ( process . env . NODE_ENV === ` production` && typeof ga === ` function` ) {
4
+ if ( process . env . NODE_ENV === ' production' && typeof ga === ' function' ) {
5
5
if (
6
6
location &&
7
- typeof window . excludeGAPaths !== ` undefined` &&
7
+ typeof window . excludeGAPaths !== ' undefined' &&
8
8
window . excludeGAPaths . some ( rx => rx . test ( location . pathname ) )
9
9
) {
10
10
return
@@ -13,17 +13,16 @@ export function onRouteUpdate({ location }) {
13
13
// wrap inside a timeout to make sure react-helmet is done with it's changes (https://github.com/gatsbyjs/gatsby/issues/9139)
14
14
// reactHelmet is using requestAnimationFrame so we should use it too: https://github.com/nfl/react-helmet/blob/5.2.0/src/HelmetUtils.js#L296-L299
15
15
const sendPageView = ( ) => {
16
- window . ga (
17
- `set` ,
18
- `page` ,
19
- location
16
+ window . ga ( 'set' , {
17
+ page : location
20
18
? location . pathname + location . search + location . hash
21
19
: undefined ,
22
- )
23
- window . ga ( `send` , `pageview` )
20
+ title : document . title ,
21
+ } )
22
+ window . ga ( 'send' , 'pageview' )
24
23
}
25
24
26
- if ( ` requestAnimationFrame` in window ) {
25
+ if ( ' requestAnimationFrame' in window ) {
27
26
requestAnimationFrame ( ( ) => {
28
27
requestAnimationFrame ( sendPageView )
29
28
} )
You can’t perform that action at this time.
0 commit comments