Amplitude には、
Google Analyticsの
JavaScript での
結果を
各言語の ライブラリに ついて
以下、
Python
marmurar/pyamplitude: A Python connector for Amplitude Analytics
管理系APIのPython の Wrapper ライブラリです。 atveit/amplitude-python: Python API for Amplitude Analytics Logging - https://amplitude.com
Amplitude のHTTP API を Pythonから 実行する ライブラリです。
Ruby
- toothrot/amplitude-api: A Ruby library for interacting with the Amplitude API Amplitude の
HTTP API を Rubyから 実行する ライブラリです。
JavaScript
amplitude/Amplitude-JavaScript: JavaScript SDK for Amplitude
Amplitude のJavaScript の Client ライブラリーです。 amplitude/react-amplitude: A React component library for easy product analytics instrumentation
React でAmplitude を 使用する ための Wrapper ライブラリーです。 Usage with nodejs · Issue #12 · amplitude/Amplitude-JavaScript
上記 Issue 内でnode.js から HTTP API を 実行する Example が 記載されています。
見て回って、
Google Apps Script から Amplitude に イベントを 送信する
以下のように
function fetchAmplitude_() { var apiKey = 'xxxxxxxxxxxxxxxxxxxx'; // ------------------ // performanceMetrics var event = new Object(); event['user_id'] = "user_id_value"; event['event_type'] = "eventName"; event['event_properties'] = { a: "xxxxx", b : "yyyyy"}; var data = { api_key: apiKey, event: JSON.stringify(event) }; var options = { "method" : "post", "payload" : data, "muteHttpExceptions": false }; UrlFetchApp.fetch('https://api.amplitude.com/httpapi', options); }
補足
以下、
apiKey
AmplitudeのAPI KEY を 設定します。 event[‘user_id’]
Amplitude のユーザーID を 設定します。
Google Apps Script から、実ユーザーの ユーザーIDを 取得できるならばそれを、 ユーザーに 紐付きのない データの 記録であれば event[‘event_type’]
イベント名を設定します。 これは、 以下 JavaScript の Client API で 設定している EVENT_TYPE
と同じ ものです。 amplitude.getInstance().logEvent('EVENT_TYPE')
event[‘event_properties’]
イベントの 属性値です。 JSON 形式で 値の 設定が できます。
参考
以下、
以上です。
GETリクエストでも
送付できるので、 メールの 開封率測定にも 使えます。 ↩
コメント