2015-06-03 27 views
5

我正在使用GoogleTagManager實施增強型電子商務(Google Analytics) 我試着將以下dataLayer推送到GTM。GoogleTagManager警告:生成器中出現意外類型:(null)

[dataLayer push:@{@"event",@"purchase", 
       @"ecommerce": @{ 
       @"purchase": @{ 
        @"actionField": @{ 
        @"id": @"T12345",       // Transaction ID. Required for purchases and refunds. 
        @"affiliation": @"Online Store", 
        @"revenue": @"35.43",      // Total transaction value (incl. tax and shipping) 
        @"tax":"4.90", 
        @"shipping": @"5.99", 
        @"coupon": @"SUMMER_SALE"}, 
        @"products": @[        // List of productFieldObjects. 
        @{@"name": @"Triblend Android T-Shirt", // Name or ID is required. 
         @"id": @"12345", 
         @"price": @"15.25", 
         @"brand": @"Google", 
         @"category": @"Apparel", 
         @"variant": @"Gray", 
         @"quantity": @1, 
         @"coupon": @""},      // Optional fields may be omitted or set to empty string. 
        @{@"name": @"Donut Friday Scented T-Shirt", 
         @"id": @"67890", 
         @"price": @"33.75", 
         @"brand": @"Google", 
         @"category": @"Apparel", 
         @"variant": @"Black", 
         @"quantity": @1}]}}}]; 

這是Google Tag管理器教程中的示例數據。 但是,當嘗試將匹配發送給Google時,我收到以下警告消息。

GoogleTagManager warning: Unexpected type in Builder: (null) 

我使用的數據類型是NSNumber的(價格[doube],收入[雙] &量[INT])&的NSString他人。

以上數據類型合適的工作像「AddToCart」等電子商務的標籤,「結帳」等。但是「購買」不工作..

任何一個可以建議還有什麼可以嘗試?

+0

我看到的第一行輸入錯誤:'[數據層推:@ {@「事件「,@」purchase「' 應該可能是:'[dataLayer push:@ {@」event「:@」purchase「'。但是我想你的代碼中有冒號,否則編譯器會抱怨。 – turingtested

+0

不適用於我:( –

回答

2

我後來遇到了這個問題。它在我看來就像與以前的電子商務的東西衝突。

之前你寄的購買事件,嘗試清除電子商務對象

[self.tagDataLayer push:@{@"ecommerce":[NSNull null]}]; 

這個工作了,我