fix: use click for gtm

This commit is contained in:
YunYouJun
2022-04-15 23:59:54 +08:00
parent 88c4cf6b22
commit 2c44f9a402
3 changed files with 11 additions and 8 deletions

View File

@@ -36,9 +36,9 @@ const gtm = useGtm()
const toggleStuff = (item: StuffItem, category = '') => { const toggleStuff = (item: StuffItem, category = '') => {
gtm?.trackEvent({ gtm?.trackEvent({
event: 'stuff', event: 'click',
category: `${category}_${item.name}`, category: `${category}_${item.name}`,
action: 'click', action: 'click_stuff',
label: '食材', label: '食材',
}) })
@@ -54,9 +54,9 @@ const clickTool = (item: StuffItem) => {
rStore.toggleTools(value) rStore.toggleTools(value)
gtm?.trackEvent({ gtm?.trackEvent({
event: 'stuff', event: 'click',
category: `tool_${value}`, category: `tool_${value}`,
action: 'click', action: 'click_tool',
label: '工具', label: '工具',
}) })
} }
@@ -151,7 +151,7 @@ const clickTool = (item: StuffItem) => {
</span> </span>
</div> --> </div> -->
<div m="2" p="2" class="transition shadow hover:shadow-md" bg="gray-400/8"> <div m="2 t-4" p="2" class="transition shadow hover:shadow-md" bg="gray-400/8">
<h2 text="xl" font="bold" p="1"> <h2 text="xl" font="bold" p="1">
🍲 今天的菜 🍲 今天的菜
<br> <br>

View File

@@ -9,9 +9,9 @@ const gtm = useGtm()
const triggerGtm = (val: string) => { const triggerGtm = (val: string) => {
gtm?.trackEvent({ gtm?.trackEvent({
event: 'recipe', event: 'click',
category: `dish_${val}`, category: `dish_${val}`,
action: 'click', action: 'click_recipe',
label: '跳转菜谱', label: '跳转菜谱',
}) })
} }

View File

@@ -3,5 +3,8 @@ import type { UserModule } from '~/types'
export const install: UserModule = ({ app }) => { export const install: UserModule = ({ app }) => {
// add google tag manager, and add GA4 in gtag // add google tag manager, and add GA4 in gtag
app.use(createGtm({ id: 'GTM-5FJSV46' })) app.use(createGtm({
id: 'GTM-5FJSV46',
debug: true,
}))
} }