Skip to content

Getting Started

GitHub

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

Terminal window
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-gtm` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

Terminal window
bun add @capgo/capacitor-gtm
bunx cap sync
import { GoogleTagManager } from '@capgo/capacitor-gtm';

Initializes Google Tag Manager with the specified container ID.

import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.initialize({} as { containerId: string; timeout?: number });

Pushes an event to the Google Tag Manager dataLayer.

import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.push({
event: 'purchase',
parameters: {
value: 99.99,
currency: 'USD'
}
});

Sets a user property in the Google Tag Manager dataLayer.

import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.setUserProperty({
key: 'user_type',
value: 'premium'
});

Gets a value from the Google Tag Manager dataLayer. Searches through the dataLayer for the most recent value of the specified key.

import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.getValue({} as { key: string });

Resets the Google Tag Manager instance and clears all data. This will remove all data from the dataLayer and require re-initialization.

import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.reset();

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.

If you are using Getting Started to plan dashboard and API operations, connect it with Using @capgo/capacitor-gtm for the native capability in Using @capgo/capacitor-gtm, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.