Skip to content

Commit

Permalink
feat: add trackers
Browse files Browse the repository at this point in the history
1. add twitter tracker
2. add google analytics tracker
  • Loading branch information
Keith-CY committed Nov 13, 2023
1 parent 5ccb76b commit a0a182a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const config = {
rules: {
'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
'import/newline-after-import': 'error',
'eol-last': ["error", "always"],
'eol-last': ['error', 'always'],
},
// This is because `next.config.mjs` is excluded from tsconfig.
ignorePatterns: ['next.config.mjs', 'next-i18next.config.js'],
ignorePatterns: ['next.config.mjs', 'next-i18next.config.js', 'public/scripts/*'],
}

module.exports = config
7 changes: 7 additions & 0 deletions public/scripts/google-analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())

gtag('config', 'G-WVH440CNZ3')
15 changes: 15 additions & 0 deletions public/scripts/twitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!(function (e, t, n, s, u, a) {
e.twq ||
((s = e.twq =
function () {
s.exe ? s.exe.apply(s, arguments) : s.queue.push(arguments)
}),
(s.version = '1.1'),
(s.queue = []),
(u = t.createElement(n)),
(u.async = !0),
(u.src = 'https://static.ads-twitter.com/uwt.js'),
(a = t.getElementsByTagName(n)[0]),
a.parentNode.insertBefore(u, a))
})(window, document, 'script')
twq('config', 'o6uy5')
6 changes: 5 additions & 1 deletion src/pages/_app.page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from 'react'
import { type AppType } from 'next/app'
import { useEffect } from 'react'
import Head from 'next/head'
import Script from 'next/script'
import { appWithTranslation } from 'next-i18next'
import localFont from 'next/font/local'
import { api } from '../utils/api'
Expand Down Expand Up @@ -29,6 +30,9 @@ const App: AppType = ({ Component, pageProps }) => {
<Head>
<title>Nervos Network</title>
<link rel="icon" type="image/svg" href="/favicon.svg" />
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WVH440CNZ3" />
<script async src="/scripts/google-analytics.js" />
<script async src="/scripts/twitter.js" />
</Head>
<main
// Here as redundancy in server-side rendering.
Expand Down

0 comments on commit a0a182a

Please sign in to comment.