Invalid macro: _gtm.loadEventEnabled when using Xamarin.GooglePlayServices.TagManager in Android
Xamarin.Android Version (eg: 6.0):
10.1.4.0
Operating System & Version (eg: Mac OSX 10.11):
Windows 10 I'm using VIsual studio 2019
Describe your Issue
Followed every step right:
- FB, GA and TM properly set up
- Install necessary nugets as stated above.
- Put the JSON of the tag manager container inside assets/containers
When I tested in iOS, it went smoothly, however in Android, I kept getting this error: Invalid macro: _gtm.loadEventEnabled
I also encounter this in the device log afterwards:
Failed to load the container. NO default container resource found with resource ID -1
then it is followed by Debug log: refresh test, containerHolder: com.google.android.gms.tagmanager.dc@XXXXXXX
Relevant information
Add relevant project settings from *.csproj file:
Packages used:
<PackageReference Include="Xamarin.GooglePlayServices.Analytics" Version="71.1608.1" />
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1610.1 />
<PackageReference Include="Xamarin.GooglePlayServices.TagManager" Version="71.1604.1 />
<PackageReference Include="Xamarin.Firebase.Analytics" Version="71.1630.1 />
<PackageReference Include="Xamarin.Firebase.Messaging" Version="71.1740.1 />
Minimal Repro Code Sample
- Create a Xamarin Forms app.
- In the Android project, install the necessary nuget packages.
- Enable firebase and call _firebaseAnalytics.SetAnalyticsCollectionEnabled(true);.
- Log some events
- Create a GA and google tag manager account. Create a container (Android), then download the JSON file. Put the JSON file inside Assets/containers folder.
- Run the application while Device logcat is running (you can check error here)
Steps to Reproduce (with link to sample solution if possible):
Include any relevant Exception Stack traces, build logs, adb logs:
I was able to fix this by just downgrading all my nugets from version 71.X to 60.X
Possibly related for more digging:
https://stackoverflow.com/questions/18883511/google-tag-manager-throws-invalid-macro-message
https://stackoverflow.com/questions/18501948/android-tagmanager-not-getting-default-values/18964099#18964099
https://www.youtube.com/watch?v=Xe8W5w68BRg&feature=youtu.be&t=8m26s
https://github.com/cwilson1031/analytics-issues/issues/635
https://en.it1352.com/article/a0acd60d21a3455299dd419b4620f627.html