简体   繁体   English

将Google跟踪代码管理器与Xamarin Google Analytics(分析)组件一起使用会导致错误

[英]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.

相关问题 适用于Xamarin iOS的Google跟踪代码管理器 - Google Tag Manager for Xamarin iOS Firebase 分析和 Google 标签管理器:<FIRAnalytics/ERROR> 事件名称已保留 - Firebase Analytics and Google Tag Manager : <FIRAnalytics/ERROR> Event name is reserved Google代码管理器错误 - Google tag manager error 在Google代码管理器中使用Universal Analytics事件代码时,事件不会显示在分析中 - Events don't show up in analytics when using Universal Analytics Event tag in google tag manager Google跟踪代码管理器iOS集成–是否向Google Analytics(分析)发送值? - Google Tag Manager iOS Integration – sending values to Google Analytics? 使用 Google Tag Manager 进行 Firebase 分析以响应原生 iOS 应用程序 - Firebase analytics with Google Tag Manager in react native iOS application Google跟踪代码管理器实施 - Google Tag Manager Implementation Google跟踪代码管理器不工作? - Google Tag Manager not Working? 如何在 Google Analytics 中获取 iOS 应用程序的 Tracking_ID 以供 Google Tag Manager 使用? - How to get a Tracking_ID in Google Analytics for iOS apps for Google Tag Manager usage? 如何提取Firebase用户参数并通过Google跟踪代码管理器发送给Google Analytics(分析)? - How to extract firebase user parameter and send to google analytics via google tag manager?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM