Mulai
Copas prompt pengaturan dengan langkah instalasi dan panduan markdown lengkap untuk plugin ini.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-gtm`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/gtm/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Instalasi
Judul bagian “Instalasi”bun add @capgo/capacitor-gtmbunx cap syncImpor
Judul bagian “Impor”import { GoogleTagManager } from '@capgo/capacitor-gtm';API Ringkasan
Judul bagian “API Ringkasan”initialize
Judul bagian “Inisialisasi”Menginisialisasi Google Tag Manager dengan ID kontainer yang ditentukan.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.initialize({} as { containerId: string; timeout?: number });Mengirimkan sebuah event ke dataLayer Google Tag Manager.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.push({ event: 'purchase', parameters: { value: 99.99, currency: 'USD' }});setUserProperty
Bagian berjudul “setUserProperty”Mengatur sebuah properti pengguna di dataLayer Google Tag Manager.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.setUserProperty({ key: 'user_type', value: 'premium'});getValue
Bagian berjudul “getValue”Mengambil nilai dari dataLayer Google Tag Manager. Mencari melalui dataLayer untuk nilai terbaru dari kunci yang ditentukan.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.getValue({} as { key: string });Mengatur ulang instance Google Tag Manager dan menghapus semua data. Hal ini akan menghapus semua data dari dataLayer dan memerlukan re-inisialisasi.
import { GoogleTagManager } from '@capgo/capacitor-gtm';
await GoogleTagManager.reset();Sumber Kebenaran
Judul bagian “Sumber Kebenaran”Halaman ini dihasilkan dari plugin’s src/definitions.tsRe-run sinkronisasi ketika publik API berubah di atas