简体   繁体   English

iOS上使用Google跟踪代码管理器进行非屏幕视图事件

[英]Non-screenview events with Google Tag Manager on iOS

we're trying to use GTM on iOS to track non-screenview events using the data layer and cannot get this to work. 我们正在尝试在iOS上使用GTM来使用数据层跟踪非屏幕视图事件,但无法使其正常工作。 First, here's our call to GTM: 首先,这是我们对GTM的致电:

NSLog(@"voted!");
NSLog(@"question: %@, answer: %@",self.question.question,selectedAnswer.answer);
[[ATITracking instance] trackEventWithTagManager:@"didVote" parameters:@{@"questionValue":self.question.question,@"voteValue":selectedAnswer.answer}];

We have 2 data layer variables set in GTM for the questionValue and the voteValue. 我们在GTM中为questionValue和表决值设置了2个数据层变量。 See: https://www.dropbox.com/s/jru5a06vs1bfmm3/variables.jpg?dl=0 参见: https : //www.dropbox.com/s/jru5a06vs1bfmm3/variables.jpg?dl=0

And here's our trigger with the event set to didVote: https://www.dropbox.com/s/0ydxml4yemji2f5/trigger.jpg?dl=0 这是事件设置为didVote的触发器: https ://www.dropbox.com/s/0ydxml4yemji2f5/trigger.jpg ? dl =0

And our event tag uses the trigger from above (cannot post link due to rep limit.) 我们的事件代码从上方使用触发器(由于rep限制,无法发布链接。)

Has anyone seen a non-screenview event tracked successfully in iOS using GTM? 有没有人看到使用GTM在iOS中成功跟踪到非屏幕视图事件? Thanks in advance. 提前致谢。

Events are working for me with no problems. 活动对我来说毫无问题。 This is slightly modified code from the GTM iOS SDK example 这是GTM iOS SDK示例中的稍作修改的代码

-(void) logEvent:(NSString*) event withProperties:(NSDictionary*) properties {
    NSMutableDictionary* eventProperties = [NSMutableDictionary dictionaryWithDictionary:@{@"event": @"customEvent",@"eventCategory":@"User action",@"eventName":event}];
    if (properties) {
        [eventProperties addEntriesFromDictionary:properties];
    }
    TAGDataLayer* dataLayer = self.tagManager.dataLayer;
    [dataLayer push:eventProperties];
}

Based on GTM documentation https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events event category and event action must not be empty. 根据GTM文档, https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events事件类别和事件操作不能为空。 I didn't see any events in GA until I configured these parameters in my tag and started pushing them from the client. 在我在代码中配置了这些参数并开始从客户端推送它们之前,我在GA中看不到任何事件。 Hope it helps. 希望能帮助到你。

Please see attached screenshot of my tag: 请查看附上我标签的屏幕截图:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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