-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5cf1c3
commit b5c8ba1
Showing
2 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
<script> | ||
import { onMount } from 'svelte'; | ||
export let measurementId; | ||
import { onMount } from 'svelte'; | ||
onMount(() => { | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag() { | ||
window.dataLayer.push(arguments); | ||
} | ||
gtag('js', new Date()); | ||
gtag('config', measurementId); | ||
let script1 = document.createElement('script'); | ||
script1.src = `https://www.googletagmanager.com/gtag/js?id=${measurementId}`; | ||
script1.async = true; | ||
document.head.appendChild(script1); | ||
let script2 = document.createElement('script'); | ||
script2.innerHTML = ` | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${measurementId}'); | ||
`; | ||
document.head.appendChild(script2); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters