Google Analytics V4: https://developers.google.com/analytics/devguides/collection/android/v4/
The instructions were updated to reflect V4 changes. Note that this library will only work with B4A v3.82+.
Setup instructions:
- Download Google Play Services from Android SDK Manager and copy google-play-services.jar to the additional libraries folder.
- Create a Mobile App Analytics account: https://support.google.com/analytics/answer/1042508
The tracker is configured with an XML file. You should create a file with the following text named analytics.xml and put it under Objects\res\xml (create this folder if needed):
Make sure to set this file to be read-only. Otherwise the IDE will delete it during compilation.
You should declare a single AnalyticsTracker in Sub Process_Globals of your main module (or other module). The single tracker should be used from all modules.
Other implemented methods: TrackEvent, SendTransaction, SendTiming and SendProduct. Note that you can pass empty strings for optional parameters.
The instructions were updated to reflect V4 changes. Note that this library will only work with B4A v3.82+.
Setup instructions:
- Download Google Play Services from Android SDK Manager and copy google-play-services.jar to the additional libraries folder.
- Create a Mobile App Analytics account: https://support.google.com/analytics/answer/1042508
The tracker is configured with an XML file. You should create a file with the following text named analytics.xml and put it under Objects\res\xml (create this folder if needed):
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-xxxxx-y</string>
<!--Enable Activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>
<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>
Make sure to set this file to be read-only. Otherwise the IDE will delete it during compilation.
You should declare a single AnalyticsTracker in Sub Process_Globals of your main module (or other module). The single tracker should be used from all modules.
B4X:
Sub Process_Globals
Public tracker As AnalyticsTracker
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
tracker.Initialize
End If
tracker.SendScreenView("Main Activity")
End Sub
Other implemented methods: TrackEvent, SendTransaction, SendTiming and SendProduct. Note that you can pass empty strings for optional parameters.
Attachments
Last edited: