Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
reslear opened this issue Sep 4, 2024 · 4 comments
Open

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

reslear opened this issue Sep 4, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@reslear
Copy link
Contributor

reslear commented Sep 4, 2024

📚 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

@reslear reslear added the help wanted Extra attention is needed label Sep 4, 2024
@reslear reslear changed the title how to load optional id how to load optional customer id Sep 4, 2024
@harlan-zw
Copy link
Collaborator

harlan-zw commented Sep 5, 2024

cc: @huang-julien, @flashdesignory some more gtag issues here if you have any ideas

@reslear reslear changed the title how to load optional customer id how to load optional customer id gtm/pixel and etc... Sep 5, 2024
@reslear reslear changed the title how to load optional customer id gtm/pixel and etc... how to load optional customer id gtag/pixel and etc... Sep 5, 2024
@reslear
Copy link
Contributor Author

reslear commented Sep 16, 2024

hi @huang-julien @flashdesignory Can you help?

@huang-julien
Copy link
Member

Hey 👋 we use TPC to generate the composable and it comes with the config event already set in the inline script property.
Currently we're only using id from the options to do it so you can't load an optional id for now.

There's currently a PR with a new templating system in TPC. We can probably try open a PR to make window['gtag-'+(options?.l ?? "dataLayer")]('config',(options?.id )) optional.

cc @flashdesignory

@reslear
Copy link
Contributor Author

reslear commented Sep 16, 2024

@huang-julien thanks for the answer!

Yes! That would be great, as some services need the ability to track the statistics of customers/sellers on their pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants