Skip to content

Commit dd9a632

Browse files
committed
docs: support multiple gtag ids
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 13ca38a commit dd9a632

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
---
22
import { siteMetadata } from '../constants.ts';
33
4-
const GTAG_ID = siteMetadata.google.gtag;
5-
const GTAG_SRC = `https://www.googletagmanager.com/gtag/js?id=${GTAG_ID}`;
4+
const GTAG_IDS = siteMetadata.google.gtags;
5+
const GTAG_SRC = `https://www.googletagmanager.com/gtag/js?id=${GTAG_IDS[0]}`;
66
---
77

88
<!-- Google tag (gtag.js) -->
99
<script async src={GTAG_SRC}></script>
10-
<script define:vars={{ GTAG_ID }}>
10+
<script define:vars={{ GTAG_IDS }}>
1111
window.dataLayer = window.dataLayer || [];
1212
function gtag() {
1313
// biome-ignore lint/complexity/noArguments: keep arguments object as per gtag.js spec
1414
dataLayer.push(arguments);
1515
}
1616
gtag('js', new Date());
1717

18-
gtag('config', GTAG_ID);
18+
GTAG_IDS.forEach((gtagId) => {
19+
gtag('config', gtagId);
20+
});
1921
</script>

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const siteMetadata = {
1313
site: 'https://setchy.io',
1414
},
1515
google: {
16-
gtag: 'G-736BKHY5WS',
16+
gtags: ['G-736BKHY5WS'],
1717
siteVerification: '',
1818
},
1919
menuLinks: [

0 commit comments

Comments
 (0)