コンテンツにスキップ

AXON 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

  1. 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”.

  2. 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>
  3. 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

NameTypeDescription
event_namestringThe name for this event. See the Events Section for available events.
event_dataobjectThe data for this event. See the Events Section below 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>

Required Events

page_view Event

To track Page View events with the AXON Pixel, under tags click New. Give the new tag a name, like AXON - Page View, then paste the following code into the Custom HTML tag configuration:

<script>
axon("track", "page_view");
</script>

view_item Event

Trigger this event when a user lands on a specific product page. To send this event, include these parameters:

NameTypeRequiredDescription
currencystringtrueThree-letter ISO 4217 code for currency
itemsAXONItem[]trueThe items for the event
valuenumberfalseMonetary value of the event, calculated by the sum of price × quantity for each item

The AXON Item Object

AXONItem is a common object required with most events. quantity, price, item_name, and item_id are required with this object and must be named and formatted exactly as shown in the table below:

NameTypeRequiredDescription
item_idstringtrueThe ID of the item
item_namestringtrueThe name of the item
pricenumbertrueThe monetary value of the item (in the user’s currency)
quantitynumbertrue*Item quantity
item_categorystringrecommendedThe category of the item
item_variantstringrecommendedThe item variant or code
image_urlstringrecommendedThe URL to an image of the item
affiliationstringfalseThe product’s affiliation to designate supplier or seller
item_brandstringfalseThe brand of the item
item_category2stringfalseThe second category of the item

*quantity not required for view_item event

add_to_cart Event

Trigger this event when a user adds an item to their cart. To send this event, include these parameters:

NameTypeRequiredDescription
currencystringtrueThree-letter ISO 4217 code for currency
itemsAXONItem[]trueThe items for the event
valuenumberrecommendedMonetary value of the items added to cart, calculated by the sum of price × quantity for each item

begin_checkout Event

Trigger this event when a user initiates the checkout process. To send this event, include these parameters:

NameTypeRequiredDescription
currencystringtrueThree-letter ISO 4217 code for currency
valuenumbertrueMonetary value of the event, calculated by the sum of price × quantity for each item
itemsAXONItem[]trueThe items for the event

purchase Event

Trigger this event when a user makes a purchase. To send this event, include these parameters:

NameTypeRequiredDescription
currencystringtrueThree-letter ISO 4217 code for currency
valuenumbertrueMonetary value of the event, calculated by the sum of price × quantity for each item
transaction_idstringtrueThe unique identifier of a transaction
itemsAXONItem[]trueThe items for the event
user_idstringrecommendedThe unique identifier for the customer
shippingnumberrecommendedShipping cost associated with the transaction
taxnumberrecommendedTax cost associated with a transaction

The remaining events listed below are recommended but not required:

remove_from_cart Event

Trigger this event when a user removes an item from their cart. To send this event, include these parameters:

NameTypeRequiredDescription
currencystringtrueThree-letter ISO 4217 code for currency
valuenumberrecommendedMonetary value of the event, calculated by the sum of price × quantity for each item
itemsAXONItem[]trueThe items for the event

generate_lead Event

Trigger this event when a lead has been generated, for example through a form. To send this event, include these parameters:

NameTypeRequiredDescription
user_idstringtrueThe unique identifier for the customer

login Event

Trigger this event when a user logs into an account on the site. To send this event, include these parameters:

NameTypeRequiredDescription
user_idstringtrueThe unique identifier for the customer

sign_up Event

Trigger this event when a user signs up for an account on the site. To send this event, include these parameters:

NameTypeRequiredDescription
user_idstringtrueThe unique identifier for the customer
methodstringrecommendedThe method used for sign up

search Event

Trigger this event when a user uses a search bar to search for content on your site. To send this event, include these parameters:

NameTypeRequiredDescription
search_termstringtrueThe term that was searched for
resultsAXONItem[]recommendedThe items for the event

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;