gtm 1.0.2 copy "gtm: ^1.0.2" to clipboard
gtm: ^1.0.2 copied to clipboard

Flutter plugin for Google Tag Manager, A solution that allows you to manage various tags such as analysis, advertising performance measurement, and affiliate marketing tracking.

example/lib/main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gtm/gtm.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  void initState() {
    super.initState();
    try {
      final gtm = Gtm.instance
        ..setCustomTagTypes([
          CustomTagType(
            'amplitude',
            handler: (eventName, parameters) {
              print('amplitude!');
              print(eventName);
              print(parameters);
            },
          ),
        ]);
      gtm.push(
        'test',
        parameters: {
          'user_no': 912342,
        },
      );
      gtm.push(
        'readCase',
        parameters: {
          'user_no': 912342,
          'user_type': 2,
        },
      );
      gtm.push(
        'buyEduCamp',
        parameters: {
          'user_no': 912342,
          'price': 10000.0,
        },
      );
    } on PlatformException {
      print('exception occurred!');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Container(),
    );
  }
}
25
likes
160
points
11.8k
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for Google Tag Manager, A solution that allows you to manage various tags such as analysis, advertising performance measurement, and affiliate marketing tracking.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter, gtm_android, gtm_ios, gtm_platform_interface, gtm_web

More

Packages that depend on gtm