接著,您就可以在 Google 代碼中設定新的 Firebase 使用者屬性變數
用於擷取 favorite_food 值的管理員:
「Variable Name」:Favorite Food
變數類型:Firebase 使用者屬性
事件參數鍵名稱:favorite_food
修改和封鎖事件
您可以使用代碼管理工具,在系統記錄事件之前,先修改及封鎖事件
Google Analytics for Firebase SDK。修改事件可協助您新增、移除或
變更事件參數值或調整事件名稱,不必更新應用程式。
Google Analytics for Firebase 會記錄未封鎖的事件
將機器學習工作流程自動化
Google Analytics for Firebase SDK 也會自動記錄部分事件,
使用者屬性。您可以在下列位置使用自動收集的事件和資源:
Google 代碼管理工具
不需要加入任何程式碼但無法加以封鎖。
3. 傳送事件
Firebase 事件名稱變數、Firebase 事件參數變數等
變數是用來設定觸發條件。系統會評估觸發條件
每次記錄 Firebase 事件時根據預設,Google Analytics for Firebase
事件。可新增 Google Analytics for Firebase
代碼來防止事件傳送至 Google Analytics。
4. 預覽、偵錯及發布容器
您可以先預覽容器版本
確保程式碼正常運作您可以透過代碼管理工具
在代碼管理工具網頁介面中產生連結和 QR code
開啟應用程式
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eGoogle Tag Manager lets you manage and update tracking tags and pixels in your iOS app without resubmitting to app stores.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can define events within their app and use Tag Manager to configure which tags should be triggered by those events.\u003c/p\u003e\n"],["\u003cp\u003eBefore publishing, you can preview and debug your Tag Manager configuration to ensure it functions as intended.\u003c/p\u003e\n"],["\u003cp\u003eOnce published, your app will automatically download the latest container updates, ensuring your tracking remains current.\u003c/p\u003e\n"],["\u003cp\u003eFirebase events and user properties are automatically available in Tag Manager for triggering tags and building variables.\u003c/p\u003e\n"]]],["Developers can use Google Tag Manager to manage measurement tags and pixels in mobile apps without app store resubmissions. This involves adding the Tag Manager package to the project via CocoaPods or Swift Package Manager and creating/downloading an iOS container in the Tag Manager account. Developers log events that are used to trigger tags and configure variables in Tag Manager, and can modify or block events. Finally, the container can be previewed, debugged, and published, allowing tag configurations to become available to users.\n"],null,["# Google Tag Manager for iOS\n\nAs a developer, you can use Google Tag Manager to implement and manage\nmeasurement tags and pixels in your mobile applications, without having to\nrebuild and resubmit application binaries to app marketplaces. Developers who\nwork with the Google Analytics for Firebase SDK can easily add Tag Manager to\nhelp manage and make changes to the implementation, even after the app has\nshipped.\n\nDevelopers can log important events and decide later which tags or pixels should\nbe fired.\n\nPrerequisites\n-------------\n\n- In the [Firebase console](https://console.firebase.google.com), add your app to your Firebase project.\n- [Set up Google Analytics](https://firebase.google.com/docs/analytics/ios/start/) for your app, including enabling Google Analytics in your Firebase project and adding the Google Analytics for Firebase SDK to your app.\n- [Create a Tag Manager account](https://tagmanager.google.com).\n- [Configure a Tag Manager container](https://support.google.com/tagmanager/answer/6103696#CreatingAnAccount).\n\nThe following sections walk you through the steps to configure and use Google\nTag Manager in your iOS application.\n\n1. Add Tag Manager to your project\n----------------------------------\n\n1. Add the Tag Manager package:\n\n ### CocoaPods\n\n To add Tag Manager via [CocoaPods](https://cocoapods.org):\n 1. In a terminal, run the following command:\n\n $ sudo gem install cocoapods\n\n 2. Change to your project directory.\n\n 3. Run the following command to create a file named `Podfile`:\n\n $ pod init\n\n 4. In `Podfile`, add the following:\n\n pod 'GoogleTagManager', '~\u003e 6.0'\n\n 5. Run the following command to download and install Tag Manager\n dependencies to your project:\n\n $ pod install\n\n ### Swift Package Manager\n\n\n To add Tag Manager via the [Swift Package Manager](https://swift.org/package-manager/):\n 1. If migrating from a CocoaPods-based project, run `pod deintegrate` to remove CocoaPods from your Xcode project. The CocoaPods-generated `.xcworkspace` file can safely be deleted afterward. If you're adding Firebase to a project for the first time, this step can be ignored.\n 2. In Xcode 12, install the Tag Manager library by navigating to **File \\\u003e Tag Manager Packages \\\u003e Add Package Dependency...**\n 3. In the prompt that appears, enter the Tag Manager GitHub\n repository:\n\n https://github.com/googleanalytics/google-tag-manager-ios-sdk.git\n\n 4. Select the version of Tag Manager you want to use. For new\n projects, we recommend using the latest version of Tag Manager.\n\n 5. Add `-ObjC` to **Other Linker Flags** in the **Build Settings** of\n your project.\n\n2. Create an iOS container if your Tag Manager account doesn't have one:\n\n 1. Sign in to your [Tag Manager](https://tagmanager.google.com) account.\n 2. In the *Accounts* tab, select your iOS container.\n 3. Click **Admin** in the top navigation bar.\n 4. On the **CONTAINER** column, click the '+' icon to create a container.\n 5. Enter a container name.\n 6. Select **iOS** container.\n 7. Click **Create**.\n3. Download your container:\n\n 1. Sign in to your [Tag Manager](https://tagmanager.google.com) account.\n 2. In the *Accounts* tab, select your iOS container.\n 3. Click *Versions* in the top navigation bar.\n 4. Select the version of the container you want to download.\n 5. Click **Download**.\n\n | **Note:** The name of the downloaded file is the container ID with a `.json` extension.\n4. Add the downloaded container to your project:\n\n 1. Copy the downloaded file into a folder called `container` in the XCode project root (usually `PROJECT_ROOT/container/GTM-XXXXXX.json`).\n 2. Open Xcode.\n 3. From the **File** menu, choose **Add files to...**\n 4. Select the `container` folder.\n 5. Click **Options** and make sure **Create folder references** is selected.\n 6. Click **Finish**.\n\n2. Log events and variables\n---------------------------\n\nTag Manager uses events, parameters, and user properties logged by the Google\nAnalytics for Firebase SDK to trigger and build tags you've configured in\nGoogle Tag Manager.\n\nRead the [Firebase developer documentation](https://firebase.google.com/docs/analytics/) for instructions on how to\n[log events](https://firebase.google.com/docs/analytics/ios/events)) and [set user properties](https://firebase.google.com/docs/analytics/ios/properties).\n\n### **Configure variables in Tag Manager**\n\nTo capture the value of event parameters and user properties for use in Google\nTag Manager, you can [configure variables](https://support.google.com/tagmanager/answer/6106899) in the Tag Manager interface.\n\nFor example, you could log the following custom event in your app: \n\n Analytics.logEvent(\"share_image\", parameters: [\n \"image_name\": name,\n \"full_text\": text\n ])\n\nThen, you could configure new Event Parameter variables in Tag Manager as\nfollows to capture the `image_name` and `full_text parameter` values:\n\n- **Variable Name**: Image Name\n- **Variable Type**: Event Parameter\n- **Event Parameter Key Name** : `image_name`\n\nand:\n\n- **Variable Name**: Full Text\n- **Variable Type**: Event Parameter\n- **Event Parameter Key Name** : `full_text`\n\nSimilarly, you could set the following user property in your app: \n\n Analytics.setUserProperty(food, forName: \"favorite_food\")\n\nThen, you could configure a new Firebase User Property variable in Google Tag\nManager to capture the `favorite_food` value:\n\n- **Variable Name**: Favorite Food\n- **Variable Type**: Firebase User Property\n- **Event Parameter Key Name** : `favorite_food`\n\n### Modify and block events\n\nTag Manager enables you to modify and block events before they are logged by the\nGoogle Analytics for Firebase SDK. Modifying events can help you add, remove, or\nchange the values of event parameters or adjust event names without app updates.\nEvents that are not blocked will be logged by the Google Analytics for Firebase\nSDK.\n\nThe Google Analytics for Firebase SDK also automatically logs some [events](https://support.google.com/firebase/answer/6317485) and\n[user properties](https://support.google.com/firebase/answer/6317486). You can use automatically collected events and properties in\nTag Manager without needing to add any code. However, you can't block them.\n\n3. Send events\n--------------\n\nFirebase event name variables, Firebase event parameter variables, and other\nvariables are used to set up [triggers](https://support.google.com/tagmanager/answer/6106961). Trigger conditions are evaluated\nwhenever you log a Firebase event. By default, Google Analytics for Firebase\nevents automatically fire. It is possible to add a Google Analytics for Firebase\ntag in Tag Manager to block events from being sent to Google Analytics.\n\n4. Preview, debug, and publish your container\n---------------------------------------------\n\nBefore publishing a version of your container, you'll want to preview it to make\nsure it works as intended. Tag Manager enables you to preview versions of your\ncontainer by generating links and QR codes in the Tag Manager web interface and\nusing them to open your application.\n\n### **Preview container**\n\nTo preview a container, generate a preview URL in the Tag Manager web\ninterface:\n\n1. Sign in to your [Tag Manager](https://tagmanager.google.com) account.\n2. Select a mobile container.\n3. Click **Versions** in the top navigation bar.\n4. Click **Actions \\\u003e Preview** on the container version you'd like to preview.\n5. Enter your application's package name.\n6. Click **Generate begin preview link**.\n\n\n **Figure 1:**Getting a preview URL from the Tag Manager web interface.\n\n \u003cbr /\u003e\n\n Save this preview URL for later steps.\n\nTo enable container previews, you must define the Tag Manager preview URL scheme\nin your project's property list. Under **URL types** of your application's\nproperty list file, register the following URL identifier and URL scheme: \n\n URL identifier: _your.package.name_\n URL scheme: tagmanager.c._your.package.name_\n\n**Figure 2:**Add the Tag Manager preview URL scheme to your application's property list file. **Note:** `your.package.name` must match the name of the app used to generate the preview URL (see Figure 1).\n\nStop your application and open the preview URL on an emulator or physical device\nto preview the draft container in your application.\n\n### **Debug container**\n\nWhen you run your app in a simulator or in preview mode, Tag Manager\nautomatically turns logging to verbose.\n\n### **Publish container**\n\nAfter you preview your container and verify that it is working, you can\n[publish it](https://support.google.com/tagmanager/answer/6107163). After you have published your container, your tag configurations\nwill become available to mobile app users.\n| **Note:** For mobile containers, a default container is used to set initial tag configurations until the first time a container is downloaded. Once the app has connected to the internet and downloaded a container, it will never use the default container again. Applications periodically check for container updates, typically every 12 hours.\n\nRelated resources\n-----------------\n\nRead [Advanced configuration](/tag-platform/tag-manager/ios/v5/advanced-config)."]]