【问题标题】:Non-screenview events with Google Tag Manager on iOSiOS 上使用 Google 跟踪代码管理器的非屏幕浏览事件
【发布时间】:2015-07-21 20:20:12
【问题描述】:

我们正在尝试在 iOS 上使用 GTM 来跟踪使用数据层的非屏幕视图事件,但无法使其正常工作。首先,这是我们对 GTM 的调用:

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

我们在 GTM 中为 questionValue 和 voteValue 设置了 2 个数据层变量。看: https://www.dropbox.com/s/jru5a06vs1bfmm3/variables.jpg?dl=0

这是我们的触发器,事件设置为 didVote: https://www.dropbox.com/s/0ydxml4yemji2f5/trigger.jpg?dl=0

我们的事件标签使用了上面的触发器(由于代表限制,无法发布链接。)

有没有人看到使用 GTM 在 iOS 中成功跟踪的非屏幕视图事件?提前致谢。

【问题讨论】:

    标签: ios objective-c google-tag-manager


    【解决方案1】:

    活动对我来说没有问题。这是来自 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];
    }
    

    基于 GTM 文档https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events 事件类别和事件操作不得为空。在我在标签中配置这些参数并开始从客户端推送它们之前,我没有在 GA 中看到任何事件。 希望对您有所帮助。

    请看我的标签截图:

    【讨论】:

    • 感谢 Dmytro。您介意在 GTM 中发布您的标签 UI 的屏幕截图吗?
    • GTM 中显示的字典中的eventCategory{{event_category}} 之间的相关性是什么?目前非常困惑,任何帮助表示赞赏!
    • @lukech eventCategory 是一个数据层变量,在我的示例中,它将从eventProperties 字典中获取eventCategory(可能是用户操作)的值。希望对你有帮助
    猜你喜欢
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多