Skip to content

@capgo/capacitor-gtm

Google Tag Manager integration for analytics and tracking

Google Tag Manager integration for analytics and tracking

Start with initialize() and the other core methods listed below.

PlatformSupportNotes
iOSYesNative
AndroidYesNative
WebNoGuard with Capacitor.getPlatform()
  • initialize - Initializes Google Tag Manager with the specified container ID.
  • push - Pushes an event to the Google Tag Manager dataLayer.
  • setUserProperty - Sets a user property in the Google Tag Manager dataLayer.
  • getValue - Gets a value from the Google Tag Manager dataLayer. Searches through the dataLayer for the most recent value of the specified key.
MethodDescription
initializeInitializes Google Tag Manager with the specified container ID.
pushPushes an event to the Google Tag Manager dataLayer.
setUserPropertySets a user property in the Google Tag Manager dataLayer.
getValueGets a value from the Google Tag Manager dataLayer. Searches through the dataLayer for the most recent value of the specified key.
resetResets the Google Tag Manager instance and clears all data. This will remove all data from the dataLayer and require re-initialization.
getPluginVersionGet the native Capacitor plugin version.

This reference is synced from src/definitions.ts in capacitor-gtm.

If you are using @capgo/capacitor-gtm to plan native plugin work, connect it with Using @capgo/capacitor-gtm for the native capability in Using @capgo/capacitor-gtm, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, and Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives.