Google 代碼管理工具支援彈性的以觸發為準 Google Ads 轉換追蹤 在 iOS 6 中使用 Google Ads 轉換追蹤代碼。本指南使用 iOS 應用程式 下載轉換檔案,示範如何設定和導入 搭配使用 Google Ads 轉換追蹤代碼和 Google 代碼管理工具。
如要為 iOS 應用程式下載設定並導入 Google Ads 轉換追蹤,請按照下列步驟進行:
1. 在 Google Ads 中建立新轉換
如要在 Google Ads 中建立新轉換,請按照下列步驟操作:
- 登入 Google Ads 帳戶。
- 在選單列中,選取「工具」>轉換。
- 按一下「+ 轉換」。
- 選取「應用程式」。
- 選取「應用程式下載」和「iOS」,然後按一下「繼續」。
- 輸入下列指令:
- 按一下「名稱」輸入 iOS 應用程式的名稱,然後 按一下「完成」。
- 按一下「價值」,為每次下載輸入一個值,或 請選取「不要為這項下載指定價值」,並且 按一下「完成」。
- 點選預設選項「最佳化」。 如要關閉最佳化功能,請按一下「開啟」,將其切換為「關閉」。 然後按一下「完成」。
- (選用) 按一下「回傳網址」,輸入來源網址 想要發布轉換的分析服務供應商 按一下「完成」。
- 按一下 [儲存並繼續]。
- 檢查轉換設定。如要變更設定,請按一下「編輯設定」。
- 在「設定追蹤方式」下方,選取「將追蹤程式碼加進應用程式」。
- 按一下「儲存操作說明和程式碼」或「以電子郵件傳送操作說明和程式碼」
儲存
conversionId和label值。 - 按一下 [完成]。
2. 建立封鎖和觸發條件
在 Google 代碼管理工具介面中,建立封鎖和啟動觸發條件, 以決定轉換追蹤代碼的觸發時機。
因為 Google Ads 轉換代碼僅適用於 iOS 6.0 或 則需要建立兩個觸發條件:
如要在 Google 代碼管理工具中建立封鎖觸發條件,請按照下列步驟操作:
- 登入 Google 代碼管理工具 讓他們使用服務帳戶
- 請選取行動容器。
- 點選左側導覽列中的「觸發條件」。
- 按一下 [新增]。
- 按一下「未命名的觸發條件」,輸入觸發條件名稱 osVersionPre6。
- 在「啟動時機」下方,輸入下列條件:

- 點選「建立觸發條件」。
如要在 Google 代碼管理工具中建立觸發條件,請按照下列步驟操作:
- 登入 Google 代碼管理工具 讓他們使用服務帳戶
- 請選取行動容器。
- 點選左側導覽列中的「觸發條件」。
- 按一下「新增」,然後選取「自訂觸發條件」。
- 按一下「未命名的觸發條件」,輸入觸發條件名稱 在事件等於 appLaunch 和平台等於 iOS 時觸發。
- 在「這項觸發條件的啟動時機」下方,選取「部分事件」,然後輸入下列條件:

- 點選「建立觸發條件」。
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
5. 記錄深層連結
如果您的應用程式使用深層連結,藉此記錄深層連結轉換,
將連結推送至資料層,做為 "gtm.url" 內的
AppDelegate 中的 application:handleOpenURL:
[[TAGManager instance].dataLayer push:@{@"gtm.url": [url absoluteString]}]; [[TAGManager instance] previewWithURL:url];
6. 發布容器
您現在可以發布容器,開始傳送轉換追蹤連線偵測 (ping) 至 Google Ads。詳情請參閱 發布和版本
如要進一步瞭解 Google Ads 轉換 追蹤,包括所有與轉換記錄方式相關的問題 請參閱 瞭解轉換追蹤。
7. 存取廣告主 ID (IDFA)
如要讓 iOS 應用程式存取 廣告客戶 (IDFA):
- 在實際目標中加入程式庫
libAdIdAccess.a。 - 在連接器選項中,指定
-ObjC或-force_Load代表實際目標。 - 在實際目標中加入
AdSupport.framework。