Bu kılavuzda
Google Analytics Measurement Protocol web ve uygulama akışı
etkinlikleri
Böylece Measurement Protocol etkinliklerini Google Analytics'te görüntüleyebilirsiniz.
Google Analytics raporlarınız .
Bu kılavuzda görmek istediğiniz platformu seçin:
Firebase
gtag.js
Google Analytics Measurement Protocol yalnızca HTTP POST
isteklerini destekler.
Bir etkinlik göndermek için aşağıdaki biçimi kullanın:
POST /mp/collect HTTP/1.1
HOST: www.google-analytics.com
Content-Type: application/json
<payload_data >
İstek URL'sinde aşağıdakileri sağlamanız gerekir:
api_secret
: Google Analytics kullanıcı arayüzünde oluşturulan API SECRET .
Yeni bir gizli anahtar oluşturmak için Yönetici bölümüne gidin > Veri Akışları > seç
canlı yayınınıza gidin > Measurement Protocol > Oluştur .
measurement_id
: Bir akışla ilişkili ölçüm kimliği. Bu kimlik:
Google Analytics kullanıcı arayüzünde Yönetici > Veri Akışları > seçtiğiniz
akış > Ölçüm Kimliği .
measurement_id
, Akış Kimliğiniz değil.
Tam referans için sorgu parametreleri bölümüne bakın.
İstek gövdesinde aşağıdakileri sağlamanız gerekir:
client_id
: Müşteri için benzersiz bir tanımlayıcıdır. Bu,
Firebase app_instance_id
gtag.js('get') kullanın.
user_id
: İsteğe bağlı. Kullanıcının benzersiz tanımlayıcısıdır. Yalnızca UTF-8 içerebilir
karakteri ekleyin. Daha fazla bilgi için Platformlar arası analiz için User-ID bölümüne bakın.
hakkında daha fazla bilgi edinin.
consent
: İsteğe bağlı. Rızayı nasıl ayarlayacağınızı öğrenin
Ayarlar 'da bulabilirsiniz.
timestamp_micros
: İsteğe bağlı. için mikrosaniye cinsinden Unix sıfır
etkinlikleri ve kullanıcı özelliklerini belirtir. Belirtilmezse varsayılan olarak
bilgi edinin .
events
: Etkinlik öğeleri dizisi. Tek bir etkinliğe birden fazla etkinlik ekleyebilirsiniz
isteğinde bulunabilirsiniz.
Kullanıcı etkinliğinin, Google Ads gibi raporlarda
Gerçek zamanlı ,
engagement_time_msec
ve session_id
,
event
için params
. engagement_time_msec
parametresi,
etkinliğin etkileşim süresini milisaniye cinsinden gösterir.
Aşağıda bununla ilgili bir örnek verilmiştir:
```jso n
{
"
clie nt _id "
: "
123456.7654321 "
,
"
eve nts "
: [
{
"
na me "
: "
campaig n _de ta ils "
,
"
params "
: {
"
campaig n _id "
: "
google_ 1234 "
,
"
campaig n "
: "
Summer_ fun "
,
"
source "
: "
google "
,
"
medium "
: "
cpc "
,
"
ter m "
: "
summer+ tra vel "
,
"
co ntent "
: "
logoli n k "
,
"
sessio n _id "
: "
123 "
,
"
e n gageme nt _ t ime_msec "
: "
100 "
}
}
]
}
```
While `sessio n _s tart ` is a [ reserved eve nt
na me ] (/a nal y t ics/devguides/collec t io n /pro t ocol/ga 4 /re feren ce#reserved_ na mes) ,
crea t i n g a ne w `sessio n _id` crea tes a ne w sessio n wi t hou t t he nee d t o se n d
`sessio n _s tart `. U n ders tan d how [ sessio ns are
cou nte d ] ( //support.google.com/analytics/answer/9191807).
## Try i t
Here's a n example you ca n use t o se n d a [ ` tut orial_begi n ` ] eve nt t o your Google
A nal y t ics server :
```javascrip t
co nst measureme nt _id = `G - XXXXXXXXXX`;
co nst api_secre t = `<secre t _value>`;
fet ch(`h tt ps : //www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`, {
me t hod : "
POST "
,
body : JSON.s tr i n gi f y( {
clie nt _id : '
XXXXXXXXXX.YYYYYYYYYY '
,
eve nts : [{
na me : '
tut orial_begi n '
,
params : {},
}]
} )
} );
```
## Override t imes ta mp
The Measureme nt Pro t ocol uses t he * f irs t * t imes ta mp i t f i n ds i n t he f ollowi n g
lis t f or each eve nt i n t he reques t :
1. The ` t imes ta mp_micros` o f t he eve nt .
1. The ` t imes ta mp_micros` o f t he reques t .
1. The t ime t ha t t he Measureme nt Pro t ocol receives t he reques t .
The f ollowi n g example se n ds a reques t - level t imes ta mp t ha t applies t o all o f
t he eve nts i n t he reques t . As a resul t , t he Measureme nt Pro t ocol assig ns bo t h t he
` tut orial_begi n ` a n d `joi n _group` eve nts a t imes ta mp o f
`reques t U n ixEpochTimeI n Micros`.
```javascrip t
{
"
t imes ta mp_micros "
: reques t U n ixEpochTimeI n Micros ,
"
eve nts "
: [
{
"
na me "
: "
tut orial_begi n "
},
{
"
na me "
: "
joi n _group "
,
"
params "
: {
"
group_id "
: "
G_ 12345 "
,
}
}
]
}
```
The f ollowi n g example se n ds bo t h a reques t - level t imes ta mp a n d a n eve nt - level
t imes ta mp. As a resul t , t he Measureme nt Pro t ocol assig ns t he ` tut orial_begi n `
eve nt a t imes ta mp o f ` tut orialBegi n U n ixEpochTimeI n Micros` , a n d t he `joi n _group`
eve nt a t imes ta mp o f `reques t U n ixEpochTimeI n Micros`.
```javascrip t
{
"
t imes ta mp_micros "
: reques t U n ixEpochTimeI n Micros ,
"
eve nts "
: [
{
"
na me "
: "
tut orial_begi n "
,
"
t imes ta mp_micros "
: tut orialBegi n U n ixEpochTimeI n Micros
},
{
"
na me "
: "
joi n _group "
,
"
params "
: {
"
group_id "
: "
G_ 12345 "
,
}
}
]
}
```
## Limi tat io ns
The f ollowi n g limi tat io ns apply t o se n di n g Measureme nt Pro t ocol eve nts t o Google
A nal y t ics :
No te : For i nf orma t io n o n t he limi tat io ns o f 360 features , see [ Google A nal y t ics
360 ] ( //support.google.com/analytics/answer/11202874).
* Reques ts ca n have a maximum o f 25 eve nts .
* Eve nts ca n have a maximum o f 25 parame ters .
* Eve nts ca n have a maximum o f 25 user proper t ies.
* User proper t y na mes mus t be 24 charac ters or fe wer.
* User proper t y values mus t be 36 charac ters or fe wer.
* Eve nt na mes mus t be 40 charac ters or fe wer , ca n o nl y co nta i n alpha - nu meric
charac ters a n d u n derscores , a n d mus t s tart wi t h a n alphabe t ic charac ter .
* Parame ter na mes i n cludi n g i te m parame ters mus t be 40 charac ters or fe wer ,
ca n o nl y co nta i n alpha - nu meric charac ters a n d u n derscores , a n d mus t s tart
wi t h a n alphabe t ic charac ter .
* Parame ter values i n cludi n g i te m parame ter values mus t be 100 charac ters or
fe wer f or a s tan dard Google A nal y t ics proper t y , a n d 500 charac ters or fe wer
f or a Google A nal y t ics 360 proper t y.
* I te m parame ters ca n have a maximum o f 10 cus t om parame ters .
* The pos t body mus t be smaller t ha n 130 kB.
* App Measureme nt Pro t ocol eve nts se nt t o Google A nal y t ics do n't popula te
Search audie n ces i n Google Ads f or app users.
For addi t io nal requireme nts o f each use case , see [ commo n use cases ] .