xamarin Google Tag Manager不会将事件发送到Google Analytics

yhived7q  于 2023-09-28  发布在  Go
关注(0)|答案(2)|浏览(130)

我正在使用Xamarin.iOS,我已经使用Google Analytics SDK(V3.10)集成了TagManager
我可以在日志中看到请求被发送到Google Analytics,但它不会显示在 Jmeter 板中。
Android和iOS都存在相同的触发规则,总是(true == true),并且在Android中工作得很好。
这是iOS中TagManager类的代码:

public class IosTagManager : NSObject, ITagManager, ITAGContainerOpenerNotifier
{
    private TAGContainer _container;

    public IosTagManager() 
    {
        var tagManager = TAGManager.GetInstance;

        tagManager.Logger.SetLogLevel(TAGLoggerLogLevelType.Verbose);
        
        var containerId = "GTM-XXXX";
        
        TAGContainerOpener.OpenContainer(containerId, tagManager, TAGOpenType.PreferNonDefault, 2.0, this);
    }

    public void Push(string key, string data)
    {
        var dict = new NSDictionary("event", key, "screenName", data);

        TAGManager.GetInstance.DataLayer.Push(dict);
    }

    public void ContainerAvailable(TAGContainer container)
    {
        _container = container;
    }
}

这是来自TagManager的日志:

2015-04-05 15:46:58.508 FormsTemplateiOS[2497:7b03] GoogleTagManager verbose: Loading default container from GTM-XXXX

2015-04-05 15:46:58.558 FormsTemplateiOS[2497:7907] GoogleTagManager debug: Resource not on disk

2015-04-05 15:46:58.561 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: scheduleTask: containerId=GTM-XXXX delay=0.000000

2015-04-05 15:46:59.128 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: Successfully loaded supplemented resource: <TAGPSupplementedResource 0x162845c0>: {
    resource {
      key: "account"
      key: "analytics_fields"
      key: "analytics_pass_through"
      key: "anonymize_ip"
      key: "arg0"
      key: "arg1"
      key: "collect_adid"
      key: "content_description"
      key: "content_group"
      key: "dimension"
      key: "ecommerce_use_data_layer"
      key: "enable_ecommerce"
      key: "fields_to_set"
      key: "function"
      key: "instance_name"
      key: "metric"
      key: "name"
      key: "tag_id"
      key: "track_appview"
      key: "value"
      value {
        type: FUNCTION_ID
        function_id: "_eq"
        101 {  # [TAGPServingValue_ext]
        }
      }
      value {
        type: FUNCTION_ID
        function_id: "_c"
        101 {  # [TAGPServingValue_ext]
        }
      }
      value {
        type: STRING
      rule {
        positive_predicate: 3
        add_macro: 15
        add_macro: 14
      }
      rule {
        positive_predicate: 4
        add_macro: 13
        remove_macro: 14
      }
      template_version_set: "0"
      version: "5"
      usage_context: "android"
      resource_format_version: 1
    }
    fingerprint: "NQ$0"
}

2015-04-05 15:46:59.170 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: Setting refresh time to current time: 1428238019170.355957

2015-04-05 15:46:59.172 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: Saving resource to disk with timestamp of 1428238019170.355957

2015-04-05 15:46:59.175 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: scheduleTask: containerId=GTM-xxxxx delay=43200000.000000

2015-04-05 15:46:59.187 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: Container refresh requested.

2015-04-05 15:46:59.190 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: scheduleTask: containerId=GTM-xxxxx delay=0.000000

2015-04-05 15:46:59.192 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: Load resource from network finished

2015-04-05 15:46:59.333 FormsTemplateiOS[2497:60b] GoogleTagManager verbose: Successfully loaded supplemented resource: <TAGPSupplementedResource 0x16105df0>: {
    fingerprint: "NQ$0"
}

2015-04-05 15:47:01.919 FormsTemplateiOS[2497:a22b] GoogleTagManager verbose: GoogleAnalytics 3.10 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:497): Saved hit: {
    parameters =     {
        "&_crc" = 0;
        "&_u" = ".4nL";
        "&_v" = "mi3.1.0";
        "&a" = 968002675;
        "&aid" = "com.xxx.xxxxx";
        "&an" = FormsTemplateiOS;
        "&av" = "1.0";
        "&cd" = MyExperts;
        "&cid" = "b894aa59-9bae-4939-b9f1-3464a1e9cc76";
        "&ds" = app;
        "&sr" = 320x480;
        "&t" = appview;
        "&tid" = "UA-xxxxxxx-xx";
        "&ul" = en;
        "&v" = 1;
        "&z" = 3890884141253459798;
        gaiVersion = "3.10";
    };
    timestamp = "2015-04-05 12:47:01 +0000";
}

2015-04-05 15:47:02.985 FormsTemplateiOS[2497:a22b] GoogleTagManager verbose: GoogleAnalytics 3.10 -[GAIRequestBuilder requestPostUrl:payload:compression:] (GAIRequestBuilder.m:167): building URLRequest for https://ssl.google-analytics.com/batch

2015-04-05 15:47:02.990 FormsTemplateiOS[2497:a22b] GoogleTagManager verbose: GoogleAnalytics 3.10 -[GAIBatchingDispatcher dispatchWithCompletionHandler:] (GAIBatchingDispatcher.m:612): Sending hit(s) POST: https://ssl.google-analytics.com/batch

2015-04-05 15:47:04.639 FormsTemplateiOS[2497:a22b] GoogleTagManager info: GoogleAnalytics 3.10 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:509): hit(s) Successfully deleted

2015-04-05 15:47:04.648 FormsTemplateiOS[2497:a22b] GoogleTagManager info: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 2 hit(s) sent

2015-04-05 15:47:04.651 FormsTemplateiOS[2497:60b] GoogleTagManager info: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:208): Hit(s) dispatched: HTTP status 200

2015-04-05 15:47:04.737 FormsTemplateiOS[2497:60b] GoogleTagManager info: GoogleAnalytics 3.10 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X000002
mf98qq94

mf98qq941#

因此,在我使用SDK一天后返回工作岗位后,一切正常,所有有关iOS系统的数据现在都显示在Analytics控制台中,无需更改任何代码。
所以这是一个24小时的等待,如谷歌官方链接here所述
如果您已安装跟踪,但在24小时后未在报告中看到数据,则可能存在以下一个或多个问题。

zte4gxcn

zte4gxcn2#

此外,您可以使用真实的视图来查看即将发生的事件。不过会有几分钟的延迟,所以要有耐心。

相关问题