Skip to content

how to load optional customer id gtag/pixel and etc... #246

Open
@reslear

Description

@reslear

📚 What are you trying to do?

I can't figure out how to load the optional id correctly
simple product page to load a consumer id in addition to the main one.

my not working example:

// /product/[id].vue

const consumerGtagId = computed(() => pageData?.gtag)

const {
  gtag,
  proxy: proxyGtag,
  load: loadGtag,
} = useScriptGoogleAnalytics({
  id: '', // without - type error 
  l: 'customer',
  key: 'gtag-customer',
  scriptOptions: {
    // consent ? 
    trigger: 'manual',
  },
})

if (consumerGtagId.value) {
  proxyGtag.gtag('config', consumerGtagId.value as any) // any - because type only `reset` 
  loadGtag()
}

🔍 What have you tried?

No response

ℹ️ Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions