Skip to content

Commit

Permalink
update gtm id (#1865)
Browse files Browse the repository at this point in the history
* update gtm id

* remove unused js

* remove unused functions
  • Loading branch information
AstDaria authored Jul 12, 2023
1 parent 9e2dcdb commit e80b4b7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 42 deletions.
3 changes: 1 addition & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ params:
twitterShareHandle: codemagicio
facebookAuthorHandle: codemagicio
appLoginLink: https://codemagic.io/
appUserUrl: http://localhost:5000/user
backendURL: http://localhost:5000
landingURL: http://localhost:3000
appURL: http://localhost:3000
Expand All @@ -14,7 +13,7 @@ params:
defaultTwitterImage: /uploads/2019/02/twitter.png
headerLinkTitle: Documentation
locale: en_GB
googleOptimizeId: 'GTM-M67KWVX'
googleTagManagerId: 'GTM-PFJ47PW'
pageRepoCommitPrefix: 'https://github.com/codemagic-ci-cd/codemagic-docs/commit/'
pageRepoEditPrefix: 'https://github.com/codemagic-ci-cd/codemagic-docs/edit/master/content/'
ignorefiles:
Expand Down
3 changes: 1 addition & 2 deletions config/production/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ buildDrafts: false
baseURL: https://docs.codemagic.io

params:
googleOptimizeId: GTM-TW39Z9J
appUserUrl: https://api.codemagic.io/user
googleTagManagerId: GTM-PFJ47PW
backendURL: https://api.codemagic.io
landingURL: https://codemagic.io
appURL: https://codemagic.io
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous" />

<script async="" src="https://www.googletagmanager.com/gtag/js?id={{ site.Param "googleOptimizeId" }}"></script>
<script async="" src="https://www.googletagmanager.com/gtag/js?id={{ site.Param "googleTagManagerId" }}"></script>

<script defer data-domain="docs.codemagic.io" src="/js/script.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
42 changes: 5 additions & 37 deletions layouts/partials/analytics.html
Original file line number Diff line number Diff line change
@@ -1,42 +1,10 @@
<script type="text/javascript">
const userFetchTimeoutMs = 3000
const analyticsId = '{{ site.Param "googleAnalyticsTrackingId" }}'
const optimizeId = '{{ site.Param "googleOptimizeId" }}'
const appUserUrl = '{{ site.Param "appUserUrl" }}'
const gtmId = '{{ site.Param "googleTagManagerId" }}'

window.dataLayer = window.dataLayer || []
function gtag() {
window.dataLayer.push(arguments)
}
;(async function() {
try {
const response = await fetchJson(appUserUrl, userFetchTimeoutMs)
if (response.user.ok) {
window.dataLayer.push({ user_state: 'User' })
}
} finally {
gtag('config', analyticsId, {
optimize_id: optimizeId,
custom_map: { dimension1: 'user_state' }
})
gtag('js', new Date())
}
})()

async function fetchJson(url, timeout) {
const options = {
mode: 'cors',
credentials: 'include',
headers: { Accept: 'application/json' }
}
const controller = new AbortController()
const signal = controller.signal

setTimeout(() => controller.abort(), timeout)

const response = await fetch(url, { ...options, signal })
return response.json()
}
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', gtmId);

!(function(f, b, e, v, n, t, s) {
if (f.fbq) return
Expand Down

0 comments on commit e80b4b7

Please sign in to comment.