mirror of
https://github.com/graphql-hive/console
synced 2026-05-24 09:38:26 +00:00
Fix missing gtag on window (#4776)
This commit is contained in:
parent
d40d548d0a
commit
90d785968c
2 changed files with 15 additions and 10 deletions
|
|
@ -4,8 +4,13 @@ export const pageview = (url: string): void => {
|
|||
if (!env.analytics.googleAnalyticsTrackingId) {
|
||||
return;
|
||||
}
|
||||
const gtag = (window as any).gtag;
|
||||
|
||||
(window as any).gtag('config', env.analytics.googleAnalyticsTrackingId, {
|
||||
page_path: url,
|
||||
});
|
||||
if (typeof gtag === 'function') {
|
||||
gtag('config', env.analytics.googleAnalyticsTrackingId, {
|
||||
page_path: url,
|
||||
});
|
||||
} else {
|
||||
console.error('window.gtag function not found');
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -101,13 +101,7 @@ function RootComponent() {
|
|||
<HelmetProvider>
|
||||
{env.analytics.googleAnalyticsTrackingId && (
|
||||
<Helmet>
|
||||
<script
|
||||
key="gtag-script"
|
||||
async
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${env.analytics.googleAnalyticsTrackingId}`}
|
||||
type="text/javascript"
|
||||
/>
|
||||
<script id="gtag-init" key="gtag-init" async type="text/javascript">{`
|
||||
<script id="gtag-init" key="gtag-init" type="text/javascript">{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
|
@ -115,6 +109,12 @@ function RootComponent() {
|
|||
page_path: window.location.pathname,
|
||||
});
|
||||
`}</script>
|
||||
<script
|
||||
key="gtag-script"
|
||||
async
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${env.analytics.googleAnalyticsTrackingId}`}
|
||||
type="text/javascript"
|
||||
/>
|
||||
</Helmet>
|
||||
)}
|
||||
<SuperTokensWrapper>
|
||||
|
|
|
|||
Loading…
Reference in a new issue