简体   繁体   中英

Google Tag Manager iOS screenName

I'm trying to send screen view to Google Analytics using Google Tag Manager. I have everything set up according to their instructions but only first several hit are properly sent to GA.

Code snippet I'm using to track screen views (I also tryed to send hardcoded screenName value):

NSDictionary *update = @{ @"event": @"openScreen",
                          @"screenName": NSStringFromClass([self class]) };

TAGDataLayer *dataLayer = [TAGManager instance].dataLayer;
[dataLayer push:update];

This is how the parameters dictionary looks before first batch dispatch to GTM. Notice that there is "&cd" parameter with screenName. Every hit until first batch dispatch contains this parameter and these screen views are properly saved to GA (I can see them in real-time overview):

GoogleTagManager verbose: GoogleAnalytics 3.13 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:517): Saved hit: {
parameters =     {
    "&_crc" = 0;
    "&_s" = 261;
    "&_u" = ".4nL";
    "&_v" = "mi3.1.3";
    "&a" = 1988848940;
    "&aid" = "my.app.id";
    "&an" = "app.name";
    "&av" = "2.1";
    "&cd" = SideMenuTableViewController;
    "&cid" = "bb292639-35a5-4782-8e45-0ba0599cf540";
    "&dm" = "iPhone7,2";
    "&ds" = app;
    "&sr" = 750x1334;
    "&t" = appview;
    "&tid" = "UA-12345678-1";
    "&ul" = "en-sk";
    "&v" = 1;
    "&z" = 3579951951005926748;
    gaiVersion = "3.13";
};
timestamp = "2015-10-13 11:27:24 +0000"; }

But after first batch dispatch "&cd" parameter is missing every time so the screen tracking stops working. Example:

GoogleTagManager verbose: GoogleAnalytics 3.13 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:517): Saved hit: {
parameters =     {
    "&_crc" = 0;
    "&_s" = 285;
    "&_u" = ".7nL";
    "&_v" = "mi3.1.3";
    "&a" = 1988848955;
    "&aid" = "my.app.id";
    "&an" = "app.name";
    "&av" = "2.1";
    "&cid" = "bb292639-35a5-4782-8e45-0ba0599cf540";
    "&dm" = "iPhone7,2";
    "&ds" = app;
    "&sr" = 750x1334;
    "&t" = appview;
    "&tid" = "UA-12345678-1";
    "&ul" = "en-sk";
    "&v" = 1;
    "&z" = 3579951951005926772;
    gaiVersion = "3.13";
};
timestamp = "2015-10-13 12:00:33 +0000"; }

Sometimes I'm also getting HTTP status code -1

GoogleTagManager info: GoogleAnalytics 3.13 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:226): Hit(s) dispatched: HTTP status -1

After 2 days it started to working properly. I have not made any changes so the problem was probably somewhere on Google's side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM