Search code examples
google-analyticsxamarin.iosxamaringoogle-tag-manager

Google Tag Manager doesn't fire events to Google Analytics


I'm using Xamarin.iOS and I have integrated TagManager using Google Analytics SDK (V3.10)

I can see in the logs that the request is sent to Google Analytics, but It is not displayed in the dashboard.

The same firing rules exits for both Android and iOS, which is always (true == true), and it works in Android great.

This is the code for the class TagManager in iOS:

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;
    }
}

This is the log from 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

Solution

  • So after returning to work a day after I used the SDK, everything worked and all the data regarding iOS system is now been displayed in Analytics console without changing any code.

    So it was a 24 hours waiting as stated in Google official link here

    "If you have installed tracking and don't see data in your reports after 24 hours, you may have one or more of the following issues." ...

    GoogleAnalytics shows iOS as well!