Add config and functionality for integrating with Google Tag Manager
Closed this issue · 0 comments
Purpose
This functionality will enable users to track app analytics using Google Tag Manager (GTM) instead of Google Analytics.
Implementation
We'll add a new config parameter called config_google_tag_manager_id
or something similar. We'll integrate it into ConfigContext
by setting it as part of the analytics object:
vectara-answer/src/contexts/ConfigurationContext.tsx
Lines 481 to 484 in d89576c
Per guidance from @aamirbutt, we'll use https://www.npmjs.com/package/analytics to integrate with GTM.
Once we add it as a dependency, we can refer to these docs when integrating it into App.tsx
, following the same pattern as the GA integration:
https://github.com/vectara/vectara-answer/blob/main/src/App.tsx#L24-L26
According to Aamir, we only need to initialize the integration in order for it to accomplish our primary goal of tracking an app visit:
Analytics({
app: 'vectara-answer',
plugins: [
googleTagManager({
containerId: 'GTM-123xyz'
})
]
})