Google タグ マネージャーでは、モバイルアプリ内の測定用のタグやピクセルの実装と管理が可能で、その際にアプリケーションのバイナリを再ビルドしてアプリ マーケットプレイスに再提出する必要もありません。Firebase 向け Google アナリティクスの SDK を使用していれば、手軽にタグ マネージャーを導入でき、実装の管理や変更がアプリの出荷後でも可能です。
Google タグ マネージャーで新しい Firebase ユーザー プロパティ変数を次のように設定すれば、favorite_food の値を取得できます。
変数名: Favorite Food
変数タイプ: Firebase ユーザー プロパティ
イベント パラメータのキー名: favorite_food
イベントを修正またはブロックする
タグ マネージャーを使用すると、Firebase 向け Google アナリティクスにログが記録される前に、イベントを変更したりブロックしたりできます。イベントを変更できると、アプリをアップデートしなくても、イベント パラメータの値の追加、削除、変更や、イベント名の調整が可能です。ブロックされていないイベントは、Firebase 向け Google アナリティクスにログが記録されます。
Firebase 向け Google アナリティクスの SDK が自動的に記録するイベントやユーザー プロパティもいくつか存在します。自動収集されているイベントやプロパティは、コードを特に追加しなくても、タグ マネージャーで活用できます。ただし、ブロックすることはできません。
3. イベントを送信する
Firebase イベント名変数、Firebase イベント パラメータ変数、その他の変数が、トリガーを設定するために使用されます。トリガー条件は、Firebase イベントをログに記録するたびに評価されます。Firebase 向け Google アナリティクスのイベントは、デフォルトでは自動的に配信されます。Firebase 向け Google アナリティクスのタグをタグ マネージャーに追加すれば、イベントがアナリティクスに送信されるのをブロックすることも可能です。
4. コンテナをプレビュー、デバッグし、公開する
あるバージョンのコンテナを公開する前に、そのコンテナをプレビューして、意図したとおりに機能することを確認する必要があります。タグ マネージャーを使用すると、タグ マネージャーの管理画面でリンクと QR コードを生成し、それらを使用してアプリを開いて、各バージョンのコンテナをプレビューできます。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-05-01 UTC。"],[[["\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)."]]