[英]Using Google Tag Manager with Xamarin Google Analytics component results in error
I'm trying to implement tracking using Google Tag Manager in an iOS app built with Xamarin, but I fail to get a container. 我正在尝试在使用Xamarin构建的iOS应用中使用Google跟踪代码管理器来实现跟踪,但是我没有获得容器。 I end up with this error in my application log: "GoogleTagManager error: notifier must be non-nil". 我最终在应用程序日志中遇到以下错误:“ GoogleTagManager错误:通知程序必须为非null”。
I used the Google Tag Manager Getting Started guide on the Google Developers website to fabricate this code piece. 我使用了Google Developers网站上的Google跟踪代码管理器入门指南来制作此代码段。
public class TagManagerService : NSObject, ITAGContainerOpenerNotifier
{
TAGContainer container;
readonly TAGDataLayer dataLayer;
readonly TAGManager tagManager;
public TagManagerService()
{
tagManager = TAGManager.GetInstance;
dataLayer = tagManager.DataLayer;
#if DEBUG
tagManager.Logger.LogLevel = TAGLoggerLogLevelType.Verbose;
#endif
TAGContainerOpener.OpenContainer(Constants.TagManagerContainerId, tagManager, TAGOpenType.PreferFresh, 0, this);
}
public void ContainerAvailable(TAGContainer container)
{
this.container = container;
}
}
This bug was fixed on latest version of Google Analytics library 3.0.10.3 according to Xamarin Dev team . 根据Xamarin Dev团队的说法,该错误已在最新版本的Google Analytics(分析)3.0.10.3中修复。
You can check the library page here for more instructions. 您可以在此处查看库页面以获取更多说明。
If you have to do take it further for enhanced ecommerce implementation, which you should be doing if wants to strength app conversion, check out my blog post on how to do it. 如果您需要做进一步以增强电子商务的实施,如果要加强应用程序转换,应该这样做,请查看我的博客文章 。
The key is on the proper object structure for nested values on gtm like below sample code 关键在于gtm上嵌套值的正确对象结构,如以下示例代码所示
NSMutableArray products = new NSMutableArray ();
if (LIST != null && LIST.Count > 0) {
foreach (var b in LIST) {
NSDictionary p = new NSDictionary ("name", b.name, "id", b.id,
"price", b.total, "category", b.category, "quantity", b.quantity);
products.Add (NSObject.FromObject (p));
}
NSDictionary actionField = new NSDictionary ("id", "value", "revenue", "value", "tax", "value", "shipping", "value", "coupon","value");
NSDictionary purchase = new NSDictionary ("purchase", new NSDictionary ("products", NSObject.FromObject(products) , "actionField", NSObject.FromObject(actionField)));
NSDictionary data = new NSDictionary ("event", "purchase", "ecommerce", NSObject.FromObject(purchase));
manager.DataLayer.Push (data);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.