Python 2.7 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Python 2.7 アプリケーションをデプロイできなくなります。既存の Python 2.7 アプリケーションは、
非推奨日以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Python に移行することをおすすめします。
Google アナリティクスとの統合
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Google アナリティクス プラットフォームでは、多様なデバイスと環境におけるビジネスとユーザーとのやり取りを測定できます。このプラットフォームは、こうしたユーザーのやり取りを収集、保存、処理、レポートするためのすべてのコンピューティング リソースを備えています。
アナリティクス コレクションは、クライアント側とサーバー側の両方で行うことができます。Google アナリティクスには、Google アナリティクスにデータを送信するための使いやすい API と SDK があります。それらに加えて、Google では、ユーザーが独自の App Engine アプリケーションで使用して、Google アナリティクスにサーバー側アナリティクスを簡単に送信できるコードも開発しています。
クライアント側アナリティクス コレクション
コレクション API と SDK を使って、ユーザーがコンテンツやマーケティング活動とどのようにやり取りをしているかを測定できます。API や SDK を実装すると、Google アナリティクスや Reporting API でユーザー操作のデータを確認できるようになります。クライアント側アナリティクス コレクションの詳細については、クライアントのタイプに応じて次のリンクを選択してください。
App Engine サーバー側アナリティクス コレクション
App Engine にはアプリケーションのイベントのロギングのメカニズムがすでに用意されていますが、Google アナリティクスで特定のサーバー側イベントを追跡することに利点がある場合があります。次のような利点があります。
- 履歴データの分析 - App Engine を使用して、ログファイルのサイズや最大日数を構成できます。その日数が経過すると、それらのログファイルにアクセスできなくなります。Google アナリティクスでイベントをトラッキングすることで、過去のイベントを表示できる期間が大幅に長くなります。
- 重要なイベントのトラッキング - アプリケーションのさまざまなコンポーネントがデータをログファイルに書き込むことによって、ログファイルが冗長になる場合があります。イベント トラッキングを使用して、モニタリングの対象とする重要なイベントだけを特定し、追加のメタデータとともにそれらをトラックできます。
- 強力なユーザー インターフェース - Google アナリティクスで提供される高機能なユーザー インターフェースを利用して、これらのサーバー側イベントを表示、レポート、エクスポートします。
これは、下記のサンプル ソースコードを App Engine アプリケーションに組み込むことによって、簡単に実現できます。この方法の詳細については、Google アナリティクス デベロッパー ガイドのイベント トラッキングをご覧ください。
サンプル ソースコード
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eThe Google Analytics Platform offers comprehensive resources for measuring user interactions across various devices and environments, covering data collection, storage, processing, and reporting.\u003c/p\u003e\n"],["\u003cp\u003eAnalytics collection can be performed on both the client and server sides, with Google Analytics providing APIs and SDKs for easy data transmission, along with pre-developed code for App Engine server-side analytics.\u003c/p\u003e\n"],["\u003cp\u003eClient-side analytics allows the tracking of user interaction with content and marketing efforts through Web Tracking, Android, iOS, and Measurement Protocol.\u003c/p\u003e\n"],["\u003cp\u003eServer-side event tracking in Google Analytics provides benefits over standard App Engine logs, including historical data analysis, focused tracking of key events, and a user-friendly interface for data visualization and reporting.\u003c/p\u003e\n"],["\u003cp\u003eThe sample code provided demonstrates how to integrate event tracking into App Engine applications, sending data directly to Google Analytics for analysis.\u003c/p\u003e\n"]]],[],null,["# Integrating with Google Analytics\n\nThe [Google Analytics Platform](/analytics/devguides/platform)\nlets you measure user interactions with your business across various devices and\nenvironments. The platform provides all the computing resources to collect,\nstore, process, and report on these user-interactions.\n\n[Analytics collection](/analytics/devguides/collection)\ncan take place on both the client and server side. Google Analytics provides\neasy to use APIs and SDKs to send data to Google Analytics. In addition to\nthose, we have developed code that you can use in your App Engine applications\nto easily send server-side analytics to Google Analytics.\n\nClient-side analytics collection\n--------------------------------\n\nWith the collection APIs and SDKs, you can measure how users interact with your\ncontent and marketing initiatives. Once implemented, you will be able to view\nuser-interaction data within Google Analytics or through the Reporting APIs.\nFor more details on client-side analytics collection select the link\nbelow based on the type of your client:\n\n- [Web Tracking (analytics.js)](/analytics/devguides/collection/analyticsjs) - Measure user interaction with websites or web applications.\n- [Android](/analytics/devguides/collection/android) - Measure user interaction with Android applications.\n- [iOS](/analytics/devguides/collection/ios) - Measure user interaction with iOS applications.\n- [Measurement Protocol](/analytics/devguides/collection/protocol/v1) - Measure user interaction in any environment with this low-level protocol.\n\nApp Engine server-side analytics collection\n-------------------------------------------\n\nAlthough App Engine already provides a mechanism for\n\n[logging events](/appengine/docs/legacy/standard/python/logs)\n\nin your application, it may be advantageous to track specific server-side events\nin Google Analytics. Some of the benefits are as follows:\n\n- **Historical data analysis** - App Engine allows you to configure the maximum number of days, or size of your log file. After that time has passed you no longer have access to those log files. Tracking events in Google Analytics provides you a much longer lifespan into the visibility of past events.\n- **Track key events** - Log files can be verbose with various components of your application writing data to them. By using event tracking you can pinpoint just the key events that you are interested in monitoring and track those along with some additional metadata.\n- **Powerful user interface** - Take advantage of the rich user interface that Google Analytics provides to visualize, report and export these server side events.\n\n\nThis can be accomplished easily by integrating the sample source code below\ninto your App Engine application. For additional information\non this approach consult the Google Analytics developers guide for\n[Event Tracking](/analytics/devguides/collection/protocol/v1/devguide#event).\n\n\u003cbr /\u003e\n\n### Sample source code\n\n def track_event(category, action, label=None, value=0):\n data = {\n 'v': '1', # API Version.\n 'tid': GA_TRACKING_ID, # Tracking ID / Property ID.\n # Anonymous Client Identifier. Ideally, this should be a UUID that\n # is associated with particular user, device, or browser instance.\n 'cid': '555',\n 't': 'event', # Event hit type.\n 'ec': category, # Event category.\n 'ea': action, # Event action.\n 'el': label, # Event label.\n 'ev': value, # Event value, must be an integer\n }\n\n response = requests.post(\n 'http://www.google-analytics.com/collect', data=data)\n\n # If the request fails, this will raise a RequestException. Depending\n # on your application's needs, this may be a non-error and can be caught\n # by the caller.\n response.raise_for_status()\n\n\n @app.route('/')\n def track_example():\n track_event(\n category='Example',\n action='test action')\n return 'Event tracked.'\n\n\u003cbr /\u003e"]]