This project is an example to configure GTM (Google Tag Manager) on app. Also, is an example to log event to GA4 (Google Analytics 4)
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
- Please refer to this link to set up 2 GTM container and relevant tags
- Download the selected container version (GTM-XXXXXXXX.json) and place them under
app/src/main/assets/containers/GTM-XXXXXX.json
folder (android) andPROJECT_ROOT/container/GTM-XXXXXX.json
folder (iOS)
To start developing locally, please follow the below steps
-
Clone the git repository and install the flutter packages.
flutter pub get
-
Log into Firebase using your Google account with the below command. (It require to install the Firebase CLI)
firebase login
-
Install the FlutterFire CLI with the following command.
(You may need to add the path of Pub to your shells' config file. Please follow the response of the command to add the path.)
dart pub global activate flutterfire_cli
-
Run the below command to configure the apps to connect to Firebase.
flutterfire configure
You may need to manually download the GoogleService-info.plist file from Firebase console. And put it in ios/Runner. Check the folder position in Xcode and rebuild it if needed.
-
Run the flutter application
flutter run
Or Open VS code to and use Run and Debug to run the application
Go Product -> Edit Scheme -> Run -> Arguments. Add 2 arguments -FIRAnalyticsDebugEnabled
and -FIRDebugEnabled
To enable Analytics debug mode on an Android device, execute the following commands: (You may need to install adb first)
adb shell setprop debug.firebase.analytics.app com.example.gtm_mobile_sample_app
This behavior persists until you explicitly disable debug mode by executing the following command:
adb shell setprop debug.firebase.analytics.app .none.
- Flutter package - firebase_analytics 10.8.0
- Debug view in Firebase - Debug events