Google Ads 转化跟踪

Google 跟踪代码管理器支持在 iOS 6 中使用 Google Ads 转化跟踪代码灵活地进行基于触发器的 Google Ads 转化跟踪。本指南通过 iOS 应用下载转化来向您介绍如何使用 Google 跟踪代码管理器配置和实现 Google Ads 转化跟踪代码。

要配置和实现针对 iOS 应用下载的 Google Ads 转化跟踪,请执行以下操作:

  1. 在 Google Ads 中创建新转化
  2. 创建屏蔽和触发型触发器
  3. 创建 Google Ads 转化跟踪代码
  4. 将转化事件推送到数据层
  5. 记录深层链接
  6. 发布容器
  7. 访问广告客户标识符 (IDFA)

1. 在 Google Ads 中创建新转化

要在 Google Ads 中创建新转化,请执行以下操作:

  1. 登录您的 Google Ads 账号。
  2. 在菜单栏中,依次选择工具 > 转化
  3. 点击 +转化
  4. 选择应用
  5. 依次选择应用下载iOS,然后点击继续
  6. 输入以下信息:
    • 点击名称,输入 iOS 应用的名称,然后点击完成
    • 点击价值,输入每次下载的价值,或者选择不为此下载操作分配价值,然后点击完成
    • 点击优化(默认处于选中状态)。 要关闭优化功能,请点击开启,将其切换为关闭,然后点击完成
    • (可选)点击回传网址,输入分析服务提供商所提供的用于发布转化数据的网址,然后点击完成
  7. 点击保存并继续
  8. 查看您的转化设置。要更改设置,请点击修改设置
  9. 设置跟踪方法下,选择将跟踪代码放入应用中
  10. 点击保存说明和代码通过电子邮件发送说明和代码,以保存 conversionIdlabel 值。
  11. 点击完成

2. 创建屏蔽和触发代码的触发器

在 Google 跟踪代码管理器界面中,创建屏蔽和触发代码的触发器,用于决定何时触发转化跟踪代码。

因为仅 iOS v6.0 或更高版本支持 Google Ads 转化代码,所以,您需要创建两个触发器:

要在 Google 跟踪代码管理器中创建屏蔽代码的触发器,请执行以下操作:

  1. 登录您的 Google 跟踪代码管理器账号。
  2. 选择一个移动容器。
  3. 在左侧导航栏中,点击触发器
  4. 点击新建
  5. 点击未命名触发器,输入触发器名称 osVersionPre6
  6. 触发条件下,输入以下条件:

    iOS version pre 6.0

  7. 点击创建触发器

要在 Google 跟踪代码管理器中创建触发代码的触发器,请执行以下操作:

  1. 登录您的 Google 跟踪代码管理器账号。
  2. 选择一个移动容器。
  3. 在左侧导航栏中,点击触发器
  4. 点击新建,然后选择自定义触发器
  5. 点击未命名触发器,输入触发器名称 fire when event equals appLaunch and platform equals iOS
  6. 此触发器的触发条件下,选择某些事件并输入以下条件:

    app launch on iOS

  7. 点击创建触发器

3. 创建 Google Ads 转化跟踪代码

在 Google 跟踪代码管理器界面中,使用以下配置值来创建新的 Google Ads 转化跟踪代码,以转化的形式跟踪应用的下载情况:

代码名称:iOS App Download Conversion
代码类型:Google Ads Conversion Tracking
转化 ID:从 Google Ads 代码段中复制 conversionId
转化标签:从 Google Ads 代码段中复制 label
转化价值:无需与 Google Ads 代码段一致
不可重复:Yes
触发型触发器:fire when event equals appLaunch and platform equals iOS
屏蔽型触发器:osVersionPre6

4. 将转化事件推送到数据层

将代码添加到您的应用,使之将触发转化的事件推送到数据层。例如,要跟踪应用下载,请在应用启动且跟踪代码管理器容器可用后,将值为 appLaunch 的事件推送一次到数据层。

//
// MyNotifier.h
//
#import "TAGContainerOpener.h"

@interface MyNotifier : NSObject<TAGContainerOpenerNotifier>

@end

//
// MyNotifier.m
//
#import "AppDelegate.h"
#import "MyNotifier.h"
#import "TAGDataLayer.h"
#import "TAGManager.h"

@implementation MyNotifier

- (void)containerAvailable:(TAGContainer *)container {

  AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

  if (appDelegate.appLaunchEventPushed == NO) {
    // Push the app launch event once after the container is opened.
    [[TAGManager instance].dataLayer push:@{@"event": @"appLaunch"}];
    appDelegate.appLaunchEventPushed = YES;
  }
}

@end

//
// AppDelegate.m
//
#import "AppDelegate.h"
#import "MyNotifier.h"
#import "TAGDataLayer.h"
#import "TAGManager.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   // MyNotifier::containerAvailable: is called when the container is opened.
  [TAGContainerOpener openContainerWithId:@"GTM-XXXX"
                               tagManager:[TAGManager instance]
                                 openType:kTAGOpenTypePreferNonDefault
                                  timeout:nil
                                 notifier:[[MyNotifier alloc] init]];

  // Rest of the method implementation.
  return YES:
}

// Rest of the AppDelegate implementation

@end

如果您的应用使用深层链接,为了记录深层链接的转化情况,请将链接作为 "gtm.url" 推送到数据层(在 AppDelegate 中的 application:handleOpenURL 内):

[[TAGManager instance].dataLayer push:@{@"gtm.url": [url absoluteString]}];
[[TAGManager instance] previewWithURL:url];

6. 发布容器

现在,您可以发布容器了,以便开始将转化跟踪 ping 数据发送到 Google Ads。有关详情,请参阅发布和版本

要详细了解 Google Ads 转化跟踪,包括有关如何报告转化的任何问题,请参阅了解转化跟踪

7. 访问广告客户标识符 (IDFA)

要让您的 iOS 应用能够访问广告客户标识符 (IDFA),请执行以下操作:

  • 在实际目标中添加库 libAdIdAccess.a
  • 在链接器选项中,指定 -ObjC-force_Load 作为实际目标。
  • 在实际目标中添加 AdSupport.framework