refactor: migrate nuxt gtm module to nuxt/scripts

This commit is contained in:
YunYouJun
2025-08-17 03:05:00 +08:00
parent 190c05918b
commit 13b6ad6047
13 changed files with 5587 additions and 3571 deletions

View File

@@ -12,7 +12,8 @@ const curStuff = computed(() => rStore.selectedStuff)
const recipeBtnRef = ref<HTMLButtonElement>()
const { playAnimation } = useEmojiAnimation(recipeBtnRef)
const gtm = useGtm()
const { proxy } = useScriptGoogleTagManager()
const recipePanelRef = ref()
const { isVisible, show } = useInvisibleElement(recipePanelRef)
@@ -22,13 +23,13 @@ function toggleStuff(item: StuffItem, category = '', _e?: Event) {
if (curStuff.value.includes(item.name))
playAnimation(item.emoji)
gtm?.trackEvent({
proxy.dataLayer.push({
event: 'click',
category: `${category}_${item.name}`,
action: 'click_stuff',
label: '食材',
})
gtm?.trackEvent({
proxy.dataLayer.push({
event: 'click_stuff',
action: item.name,
})