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

Feat/add gtag #1652

Merged
merged 7 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,50 @@ const projectKey =

/** @type {import('@docusaurus/types').Config} */
const config = {
headTags: [
{
tagName: 'script',
attributes: {
type: 'text/javascript',
src: 'https://www.googletagmanager.com/gtag/js?id=G-T8KHTQMBG8'
}
},
{
tagName: 'script',
attributes: {
type: 'text/javascript',
src: 'https://app.termly.io/resource-blocker/22740907-ba21-41a3-bbd9-106afc077eab?autoBlock=on'
devceline marked this conversation as resolved.
Show resolved Hide resolved
}
},
{
tagName: 'script',
attributes: {
type: 'text/javascript',
defer: 'true'
},
innerHTML: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-T8KHTQMBG8');
`
},
{
tagName: 'script',
attributes: {
type: 'text/javascript',
defer: 'true'
},
innerHTML: `
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5557TG59');
`
}
],
title: 'WalletConnect Docs',
tagline: 'WalletConnect is an open protocol to communicate securely between Dapps and Wallets.',
url: 'https://docs.walletconnect.com/',
Expand All @@ -25,7 +69,7 @@ const config = {
scripts: [
{
src: 'https://plausible.io/js/plausible.js',
defer: true,
defer: 'true',
'data-domain': 'docs.walletconnect.com'
}
],
Expand Down Expand Up @@ -152,6 +196,17 @@ const config = {
href: 'https://warpcast.com/walletconnect/'
}
]
},
{
title: 'Privacy',
items: [
{
href: '#',
id: 'termly-display-preferences',
class: 'termly-display-preferences footer__link-item',
label: 'Consent Preferences'
}
]
}
],
copyright: `Copyright © ${new Date().getFullYear()} WalletConnect, Inc.`
Expand Down
32 changes: 30 additions & 2 deletions src/theme/Root.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
import React from 'react'
import React, { useEffect } from 'react'
import { DocsSidebarProvider } from '@docusaurus/theme-common/internal'

export default function Root({ children }) {
return <DocsSidebarProvider>{children}</DocsSidebarProvider>
useEffect(() => {
// Need to replace the consent prefences button after render due
devceline marked this conversation as resolved.
Show resolved Hide resolved
devceline marked this conversation as resolved.
Show resolved Hide resolved
// to the loading order of docusaurus scripts and footer tags.
setTimeout(() => {
const termlyATag = document.createElement('a')
termlyATag.href = '#'
termlyATag.className = 'termly-display-preferences footer__link-item'
termlyATag.innerHTML = 'Consent Preferences'
document.getElementById('termly-display-preferences')?.parentElement.append(termlyATag)
document.getElementById('termly-display-preferences')?.remove()
}, 0)
}, [])

return (
<>
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-5557TG59"
height="0"
width="0"
style={{
display: 'none',
visibility: 'hidden'
}}
></iframe>
</noscript>
<DocsSidebarProvider>{children}</DocsSidebarProvider>
</>
)
}