Tag Manager API - Referensi Kamus Makro

Dokumen ini menjelaskan properti yang dapat ditetapkan untuk makro Google Tag Manager.

Pengantar

Setiap Makro Google Tag Manager memiliki kode type untuk mengidentifikasi makro. Selain itu, sebagian besar makro memiliki parameter (pasangan key, type ) yang dapat Anda tetapkan sebagai bagian dari "objek parameter" saat membuat atau memperbarui makro. Untuk mempelajari lebih lanjut cara menetapkan parameter ini menggunakan objek parameter, lihat Referensi Parameter.

Bagian tersisa dari dokumen ini mencantumkan detail semua makro yang didukung.

Cookie Pihak Pertama

Ketik kode

k

Parameter

Kunci Jenis Catatan
name template Nama cookie.

Contoh

 {
   "name": "Sample 1st Party Cookie Macro",
   "type": "k",
   "parameter": [
    {
     "type": "template",
     "key": "name",
     "value": "myCookieName"
    }
   ]
 }

Variabel Peristiwa Otomatis

Ketik kode

aev

Parameter

Kunci Jenis Catatan
varType template Salah satu dari ELEMENT,CLASSES, ID, TARGET, TEXT, URL, HISTORY_NEW_URL_FRAGMENT, HISTORY_OLD_URL_FRAGMENT, HISTORY_NEW_STATE, HISTORY_OLD_STATE, HISTORY_CHANGE_SOURCE.
defaultValue template Opsional.

Contoh

  {
   "name": "Sample AutoEvent Variable",
   "type": "aev",
   "parameter": [
    {
     "type": "template",
     "key": "varType",
     "value": "CLASSES"
    },
    {
     "type": "template",
     "key": "defaultValue",
     "value": "MyDefault"
    }
   ]
  }

String Konstan

Ketik kode

c

Parameter

Kunci Jenis
value template

Contoh

  {
   "name": "Sample Constant String",
   "type": "c",
   "parameter": [
    {
     "type": "template",
     "key": "value",
     "value": "MyString"
    }
   ]
  }

Nomor Versi Penampung

Ketik kode

ctv

Parameter

T/A

Contoh

  {
   "name": "Sample Container Version Number",
   "type": "ctv"
  }

Peristiwa Kustom

Ketik kode

Parameter

T/A

Contoh

  {
   "name": "Custom Event Name",
   "type": "e"
  }

JavaScript Kustom

Ketik kode

jsm

Parameter

Kunci Jenis
javascript template

Contoh

  {
   "name": "Sample Custom Javascript",
   "type": "jsm",
   "parameter": [
    {
     "type": "template",
     "key": "javascript",
     "value": "function() {\n return \"Hello World\";\n}"
    }
   ]
  }

Variabel Lapisan Data

Ketik kode

v

Parameter

Kunci Jenis Catatan
name template Nama variabel lapisan data.
defaultValue template
dataLayerVersion integer 1 atau 2.

Contoh

  {
   "name": "Sample Data Layer Variable",
   "type": "v",
   "parameter": [
    {
     "type": "template",
     "key": "name",
     "value": "DL Variable Name"
    },
    {
     "type": "template",
     "key": "defaultValue",
     "value": "DEFAULT"
    },
    {
     "type": "integer",
     "key": "dataLayerVersion",
     "value": "2"
    }
   ]
  }

Mode Debug

Ketik kode

dbg

Parameter

T/A

Contoh

  {
   "name": "Sample Debug Mode Macro",
   "type": "dbg"
  }

Elemen DOM

Ketik kode

d

Parameter

Kunci Jenis Catatan
elementId template
attributeName template Opsional.

Contoh

  {
   "name": "Sample DOM Element Macro",
   "type": "d",
   "parameter": [
    {
     "type": "template",
     "key": "elementId",
     "value": "MyElementId"
    },
    {
     "type": "template",
     "key": "attributeName",
     "value": "MyAttributeName"
    }
   ]
  }

Perujuk HTTP

Ketik kode

f

Parameter

Kunci Jenis Catatan
component template Salah satu dari: URL, PROTOCOL, HOST, PORT, PATH, QUERY, FRAGMENT.
stripWww boolean Untuk komponen = HOST
queryKey template Untuk komponen = QUERY

Contoh

  {
   "name": "Sample HTTP Referrer Macro",
   "type": "f",
   "parameter": [
    {
     "type": "template",
     "key": "component",
     "value": "URL"
    }
   ]
  }

Variabel JavaScript

Ketik kode

j

Parameter

Kunci Jenis Catatan
name template Nama variabel global.

Contoh

  {
   "name": "Sample Javascript Variable",
   "type": "j",
   "parameter": [
    {
     "type": "template",
     "key": "name",
     "value": "MyGlobalVarName"
    }
   ]
  }

Tabel Pencarian

Ketik kode

smm

Parameter

Kunci Jenis Catatan
input template Nilai yang digunakan untuk pencarian, harus berupa referensi makro.
map list Daftar peta, masing-masing dengan satu pasangan [key, value].
map[].key template
map[].value template
defaultValue template Opsional.

Contoh

  {
   "name": "Sample Lookup Table Macro",
   "type": "smm",
   "parameter": [
    {
     "type": "template",
     "key": "input",
     "value": "{{event}}"
    },
    {
     "type": "list",
     "key": "map",
     "list": [
      {
       "type": "map",
       "map": [
        {
         "type": "template",
         "key": "key",
         "value": "EventEqualsThis"
        },
        {
         "type": "template",
         "key": "value",
         "value": "ThenSetToThis"
        }
       ]
      }
     ]
    },
    {
     "type": "template",
     "key": "defaultValue",
     "value": "MyDefaultValue"
    }
   ]
  }

Angka Acak

Ketik kode

r

Parameter

T/A

Contoh

  {
   "name": "Sample Random Number Macro",
   "type": "r"
  }

URL

Ketik kode

u

Parameter

Kunci Jenis Catatan
component template Salah satu dari: URL, PROTOCOL, HOST, PORT, PATH, QUERY, FRAGMENT.
customUrlSource template Opsional.
stripWww boolean Untuk komponen = HOST.
queryKey template Untuk komponen = QUERY.

Contoh

  {
   "name": "Sample URL Macro",
   "type": "u",
   "parameter": [
    {
     "type": "template",
     "key": "component",
     "value": "URL"
    },
    {
     "type": "template",
     "key": "customUrlSource",
     "value": "{{element}}"
    }
   ]
  }