forked from teamdigitale/padigitale2026.gov.it-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
35 lines (30 loc) · 865 Bytes
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
import { Layout } from './src/layouts/Layout';
import config from './gatsby-config.js';
export const wrapPageElement = ({ element, props }) => <Layout {...props}>{element}</Layout>;
const mamotoTracking = (location) => {
const { _paq } = window;
if (!_paq) {
return;
}
const { title } = document;
const url = location && location.pathname + location.search + location.hash;
_paq.push(['setCustomUrl', url]);
_paq.push(['setDocumentTitle', title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
};
const gaTracking = () => {
const { ga } = window;
if (!ga) {
return;
}
ga('send', 'pageview');
};
export const onRouteUpdate = ({ location }) => {
const isProd = location.host === config.siteMetadata.hostname;
if (isProd) {
mamotoTracking(location);
gaTracking();
}
};