AXON Pixel Google Tag Manager Integration
このコンテンツはまだ日本語訳がありません。
This guide assumes that you have a Google Tag Manager (GTM) account with a Data Layer that receives e-commerce events such as viewing a product, add to cart, and checkout.
This guide also assumes that you are familiar with the core GTM concepts: tags, triggers, variables, and the data layer. This guide does not explain how to set up the Data Layer to provide data to GTM.
Installing the AXON Pixel
-
Log in to your Google Tag Manager account. Click your website’s container, and under Tags, click New. For Tag Configuration, choose Custom HTML. Enter a name, for example “AXON — Init”.
-
Copy and paste the following code into your tag. Replace “«your-event-key»” with the key from your AppLovin Account.
<script>var AXON_EVENT_KEY="«your-event-key»";!function(e,r){var t=["https://s.axon.ai/pixel.js","https://c.albss.com/p/l/loader.iife.js"];if(!e.axon){var a=e.axon=function(){a.performOperation?a.performOperation.apply(a,arguments):a.operationQueue.push(arguments)};a.operationQueue=[],a.ts=Date.now(),a.eventKey=AXON_EVENT_KEY;for(var n=r.getElementsByTagName("script")[0],o=0;o<t.length;o++){var i=r.createElement("script");i.async=!0,i.src=t[o],n.parentNode.insertBefore(i,n)}}}(window,document);axon("init");</script> -
Click under Triggering and select Initialization - All Pages. This ensures that the AXON Pixel loads on all pages. Click Save.
Tracking Events with the AXON Pixel
To send an occurrence of an e-commerce event to AXON, use the following syntax. Each event should trigger when its corresponding event happens in the data layer.
<script> axon("track", «event-name», «event-data»);</script>
Parameters
Name | Type | Description |
---|---|---|
event_name | string | The name for this event. See AXON Pixel Events and Objects for available events. |
event_data | object | The data for this event. See AXON Pixel Events and Objects for data to send. (Note: you do not need to send event_data with page_view .) |
All events require the event_name
argument.
Each event except for page_view
also requires certain event_data
, described in the event-specific sections below.
Passing Data to the AXON Pixel
There are two ways to populate the event in GTM:
Method 1: Single GTM Variable
For each of the events that require event_data
, AppLovin recommends that you create a GTM Variable that is the payload.
For example,
<script> axon("track", "add_to_cart", {{ AXON - Add To Cart }} );</script>
(where {{ AXON - Add To Cart }}
is a GTM Variable you create).
Method 2: Composition of GTM Variables
You can also build the object composed of multiple Variables. For example:
<script> axon("track", "add_to_cart", { "currency": "USD", "value": {{ AXON - Add To Cart - Value }}, "items": {{ AXON - Add To Cart - Items }} } )</script>
Enhanced User Identification (Recommended)
The AXON Pixel sets the first-party cookie _axwrt
to identify users.
This cookie is automatically sent in every request to your website.
To enhance user identification, AppLovin strongly recommends that you perform the following on the back-end of your site:
Whenever you see the cookie _axwrt
in an HTTP request, set the HTTP response such that it includes a header that sets a new first-party HTTP cookie axwrt
(removing the underscore) with a one-year expiration date.
- The value of this cookie should be the same as the value of the corresponding cookie passed in the request.
- The domain for the cookie should be your site, prefixed with a period.
For example, if your site is
mysite.com
, the domain attribute should be.mysite.com
. Note: “www” should not be included here. - The path for the cookie should be
/
. - Do not set the cookie to be
HttpOnly
.
For example, if your site sees an HTTP request where the value of cookie _axwrt
is xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
, then add to your response the header:
Set-Cookie: axwrt=xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx;Expires=«One Year from Today»; Domain=«.mysite.com»; Path=/; SameSite=Lax;