Question

Note: It has been posed already in the post: Quantities of items are not tracked in google analytics transactions but not answered.

When using Google Tag Manager ([edit] Release Version 3.06) for iOS (Objective-C) and sending a purchase event like described in the example the event gets send and I can read it back in the Google Analytics backend, however the value for quantity is always 0 (zero). The price is 0 (zero) as well, but I'm not sure if this is caused by the quantity being 0. Every other parameter seems to be sent just fine.

Note that I implemented the android SDK with no problems.

The code as it is now is (altered for readability):

int quantity = 1;
float price = 0.89f;
float shipping = 0.0f;
float tax = 0.0f;

TAGDataLayer *dataLayer = [TAGManager instance].dataLayer;

NSMutableArray *purchasedItems = [NSMutableArray array];

[purchasedItems addObject:@{@"name": GetStringParam(name),
                            @"sku": GetStringParam(SKU),
                            @"category": GetStringParam(category),
                            @"price": [NSNumber numberWithFloat:price],
                            @"currency": @"EUR",
                            @"quantity": [NSNumber numberWithInt:quantity]
                            }];

[dataLayer push:@{@"event": @"Transaction",
                  @"transactionId": GetStringParam(transactionID),
                  @"transactionTotal": [NSNumber numberWithInt:quantity],
                  @"transactionAffiliation": GetStringParam(affiliation),
                  @"transactionTax": [NSNumber numberWithFloat:tax],
                  @"transactionShipping": [NSNumber numberWithFloat:shipping],
                  @"transactionCurrency": @"EUR",
                  @"transactionProducts": purchasedItems
                  }];

[dataLayer push:@{@"transactionId": [NSNull null],
                  @"transactionTotal": [NSNull null],
                  @"transactionAffiliation": [NSNull null],
                  @"transactionTax": [NSNull null],
                  @"transactionShipping": [NSNull null],
                  @"transactionCurrency": [NSNull null],
                  @"transactionProducts": [NSNull null]
                  }];

Am I doing something wrong or is the a known issue for the GTM SDK for iOS? I would really love to get some help on this.

UPDATE: Just wanted to add the log that GTM generates:

Saved hit: {
parameters =     {
    "&_u" = ".L";
    "&_v" = "mi3.0.6";
    "&aid" = "[this is confidential]";
    "&an" = "[this is confidential]";
    "&av" = "[this is confidential]";
    "&cd" = "/Home";
    "&cid" = "60dc5171-1a8d-40ed-9f90-cc2cb1bbb30d";
    "&cu" = EUR;
    "&ic" = "Test-SKU";
    "&in" = "Test-name";
    "&ip" = "0.89";
    "&iq" = 1;
    "&iv" = "Test-category";
    "&sr" = 320x480;
    "&t" = item;
    "&ti" = "TEST-PURCHASE_JXJKY0N8";
    "&tid" = "UA-XXXXXX-2";
    "&ul" = en;
    "&v" = 1;
    "&z" = 12665685598291294076;
    gaiVersion = "3.06";
};
timestamp = "2014-04-10 11:02:23 +0000";
}

If any additional info is needed, please let me know.

Cheers, Niels

Was it helpful?

Solution

There's a bug in the current (3.06 version) of the iOS SDK such that you shouldn't provide NSNumbers as values in the ecommerce event that you push. The workaround is to use strings instead (e.g., [NSString stringWithFormat @"%1.2f", price]).

We're working on fixing the bug.

Neil (Google Tag Manager for Mobile Apps Tech Lead)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top