-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: e2e integration tests for ga and gtm (#189)
Co-authored-by: harlan <[email protected]>
- Loading branch information
1 parent
9285284
commit d730eb5
Showing
3 changed files
with
87 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="ts" setup> | ||
import { useHead, useScriptGoogleAnalytics } from '#imports' | ||
useHead({ | ||
title: 'Google Analytics', | ||
}) | ||
// composables return the underlying api as a proxy object and a $script with the script state | ||
const { gtag, $script } = useScriptGoogleAnalytics({ | ||
id: 'G-TR58L0EF8P', | ||
}) | ||
function triggerConversion() { | ||
gtag('event', 'conversion') | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<ClientOnly> | ||
<div> | ||
status: {{ $script.status.value }} | ||
</div> | ||
</ClientOnly> | ||
<button @click="triggerConversion"> | ||
Trigger Conversion | ||
</button> | ||
</div> | ||
</template> |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="ts" setup> | ||
import { useScriptGoogleTagManager } from '#imports' | ||
const { dataLayer, $script } = useScriptGoogleTagManager({ | ||
id: 'GTM-MNJD4B', | ||
}) | ||
function pushEvent() { | ||
dataLayer.push({ | ||
event: 'page_view', | ||
page_title: 'GTM', | ||
}) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<ClientOnly> | ||
<div> | ||
status: {{ $script.status }} | ||
</div> | ||
</ClientOnly> | ||
|
||
<button @click="pushEvent"> | ||
trigger | ||
</button> | ||
</div> | ||
</template> |