Skip to Content
iAdvizeDocs

Install with Google Tag Manager

Install the agent's tag and report orders and add-to-carts from Google Tag Manager, on every platform except Shopify. Import the Main Tag and Sales templates, create the two tags, test them with Preview, publish, and fix what goes wrong.

On every platform except Shopify, you can install the agent from your Google Tag Manager (GTM) web container instead of pasting code into your store. iAdvize gives you two GTM templates, downloaded from Site settings > Installation:

TemplateWhat its tag doesWhere it fires
iAdvize - Main TagInstalls the agent's tag, exactly as the install snippet does. Its one field, Site public key, is already filled in with your site's key.On every page, when the page has finished loading.
iAdvize - SalesReports each completed order with the transaction command and each product added to the cart with the addToCart command.On your store's purchase and add-to-cart dataLayer events.

You need both. The Sales tag does not send anything itself: it hands each order and each add to the agent's tag, which sends them. On a page where the agent's tag is not installed, the Sales tag records nothing. So the Main Tag (or the snippet) must run on every page where the Sales tag fires, the order confirmation page included.

The order in which they fire does not matter. When the Sales tag fires before the agent's tag has loaded, its calls wait in the tag's queue and are sent once the tag loads.

On Shopify, use the Shopify guide instead: the snippet in your theme and the Shopify pixel.

Before you start

  • Your GTM web container runs on every page of your store, the order confirmation page included.
  • You can see the install snippet on Site settings > Installation. The same members can download the two templates.
  • For the Sales tag, your store pushes its orders and add-to-carts to the dataLayer. The template reads the GA4 ecommerce format (purchase and add_to_cart events) by default. Another format works too: you map it in the template, with no code (see If your dataLayer is not in the GA4 format).

If the install snippet is already in your pages, the Main Tag sees it and loads nothing more, so the agent's tag never loads twice. The snippet's key is the one used.

Download the templates

Open the site in the dashboard and go to Site settings > Installation:

  • the Install the tag card downloads the Main Tag template, with your site's public key already filled in;
  • the Track your sales card downloads the Sales template. It carries no key, so the same file works for every site.

The Install the tag card of the Installation tab on a site whose platform is not Shopify: Google Tag Manager marked Recommended, the Import the template and Create the tag and publish steps, with the Download Main Tag button highlighted.

The Track your sales card on a site whose platform is not Shopify: the note that the Sales tag needs the tag on the same pages, the Google Tag Manager steps with the Download Sales template button highlighted, then the Orders received and Add-to-carts received rows.

Import a template

Do this once per container for each template.

In Google Tag Manager, open your container and go to Templates. Under Tag templates, click New.

In the More actions menu (the three dots at the top right), choose Import, then pick the .tpl file you downloaded.

Google Tag Manager, the Template Editor of a new tag template: the More actions menu at the top right is open on Import.

Click Save. The template now shows under Tag templates as iAdvize - Main Tag or iAdvize - Sales.

Create the Main Tag

Go to Tags and click New.

In Tag configuration, pick iAdvize - Main Tag. The Site public key field already holds your site's key (pk_site_…). Do not change it. Once the tag is saved, the card only shows the template's name: click it to see the field again.

Google Tag Manager, a new tag of type iAdvize - Main Tag: the Site public key field holds the site's key.

In Triggering, choose a Window Loaded trigger that fires on all pages. A new container has none: All Pages is a Page View trigger, which fires as soon as the page starts loading, not a Window Loaded one. To create it, click + in Firing Triggers, then + at the top right of the list, then Trigger Configuration, and pick Window Loaded in the Page View group: the trigger type reads Page View - Window Loaded. Under This trigger fires on, keep All Window Loaded Events. Name it (for example "Window Loaded - All pages"), save it, and it is added to the tag.

Google Tag Manager, a new trigger named Window Loaded - All pages: trigger type Page View - Window Loaded, firing on All Window Loaded Events.

Save the tag. Then test and publish.

Why Window Loaded. The install snippet waits for the page's load event before it loads anything, so the agent's tag never competes with your page's first render. A GTM template cannot wait for that event itself, so the trigger does the waiting. All Pages fires earlier, while your page is still loading: don't use it for the Main Tag.

Create the Sales tag

Install the Main Tag first: without it, the Sales tag records nothing.

Go to Tags and click New.

In Tag configuration, pick iAdvize - Sales. If your dataLayer uses the GA4 format, leave My dataLayer does not use the GA4 format unticked: there is nothing to fill. Otherwise, see If your dataLayer is not in the GA4 format.

Google Tag Manager, the iAdvize - Sales tag: My dataLayer does not use the GA4 format unticked, and two firing triggers, Custom Event - Add to Cart or Custom Event - Purchase.

In Triggering, add two Custom Event triggers, one for your purchase event and one for your add-to-cart event. In Google Tag Manager a tag runs only when one of its triggers fires: the Sales tag does not watch the dataLayer by itself. A Custom Event trigger fires each time your site pushes an event of that name to the dataLayer, so with these two triggers the Sales tag runs at each purchase and each add to cart, and at no other moment. The moment the agent's tag loads is the Main Tag's trigger, not this one. For each: click + in Firing Triggers, then + at the top right of the list, then Trigger configuration, pick Custom Event, enter the event name (purchase, then add_to_cart), name the trigger and save it. If a trigger for that event already exists in your container (for GA4, for example), add it instead of creating a new one.

If your store pushes other names (purchase_custom, for example), use those names in the triggers, and the same names in the tag's mapping (see below). The two must match: the tag compares the name of the event that fired it with the names in its mapping, and on any other name it runs but sends nothing.

Google Tag Manager, the Custom Event - Purchase trigger: Event name purchase, Use regex matching unticked, firing on All Custom Events.

Save the tag. Then test and publish.

One tag handles both events: it reads the name of the event that fired it. On the purchase event, it reports the order. On the add-to-cart event, it reports each product line added, one add per line. Any other event sends nothing.

What the Sales tag reads in the GA4 format

EventValues read when the tag fires
purchaseecommerce.transaction_id (the order reference), ecommerce.value (the amount), ecommerce.currency, and the lines in ecommerce.items
add_to_cartecommerce.currency and the lines in ecommerce.items, each with item_id, item_variant, quantity and price. A line with no quantity counts as one unit.

Push ecommerce: null before each GA4 event, as Google recommends, so a value left over from an earlier event is never read.

The tag reads nothing else from the dataLayer: no email, no name, no address, no cookie. The tag hands the order's lines to the agent's tag, which does not send them yet: only the order total is recorded (see Limits).

If your dataLayer is not in the GA4 format

Tick My dataLayer does not use the GA4 format. Two sections appear, Purchase and Add to cart, each with:

  • the event name, prefilled with the GA4 name (purchase, add_to_cart). Use the same names in the trigger;
  • the values: for a purchase the order reference, amount, currency and products; for an add to cart the currency and the products added. Left empty, a field reads its GA4 key. To read your own key, put a GTM variable in the field, for example a Data Layer Variable that points to it;
  • the line keys: the names of the product id, variant, quantity and unit price keys in each product line (plus the unit discount for a purchase), prefilled with the GA4 names. Each event has its own, so a store whose two events describe products differently is covered.

Google Tag Manager, the iAdvize - Sales tag with My dataLayer does not use the GA4 format ticked: the Purchase section shows the event name, the order reference, amount and currency, then the product lines and their keys.

The order amount can be a number or a decimal string. A comma works as the decimal separator only when it is the only separator and one or two digits follow it: 59,90 is read as 59.90, while 1,234 is refused, never guessed. The other rules on each value are those of the transaction command and the addToCart command.

Your container now holds the two tags, each with its triggers:

Google Tag Manager, the Tags list: iAdvize - Main Tag fired by Window Loaded - All pages, and iAdvize - Sales fired by Custom Event - Add to Cart and Custom Event - Purchase.

and three triggers, each used by one tag:

Google Tag Manager, the Triggers list: Custom Event - Add to Cart, Custom Event - Purchase and Window Loaded - All pages, each used by one tag.

Test and publish

In your workspace, click Preview (top right). Tag Assistant opens: enter the address of a page of your store and click Connect. Your store opens in a new window, with this container's unpublished changes. It works only on a site where this container is already installed (the Google Tag Manager snippet in its pages).

Browse a page, add a product to the cart and place a test order. If your store does not push its add_to_cart and purchase events yet, you can push one by hand to check the Sales tag: in the store window, open the browser's console and run, for example, dataLayer.push({ ecommerce: null }); dataLayer.push({ event: 'add_to_cart', ecommerce: { currency: 'EUR', items: [{ item_id: 'TEST-1', quantity: 1, price: 10 }] } }). That add is recorded like a real one. In Tag Assistant, check that iAdvize - Main Tag fired on the Window Loaded event, and that iAdvize - Sales fired on your purchase and add-to-cart events.

Tag Assistant in Preview, the Window Loaded event: iAdvize - Main Tag under Tags Fired, iAdvize - Sales under Tags Not Fired.

On the Window Loaded event, only the Main Tag fires: the Sales tag waits for a purchase or an add to cart. Click iAdvize - Sales to see the events it fired on and its triggers:

Tag Assistant, details of the iAdvize - Sales tag: it fired on an add_to_cart message, with its two triggers, _event equals purchase and _event equals add_to_cart.

When both tags fire as expected, click Submit, then Publish. Nothing reaches your shoppers until the container is published.

A test order counts like a real one, and there is no way to delete it. Use a low amount, or a site you keep for testing.

Check it in the dashboard

On Site settings > Installation, the Track your sales card shows two rows, Orders received and Add-to-carts received. Each one reads that nothing was received yet until the first order or add arrives from your store, then the date and time of the latest one. When Record orders from your store or Count add-to-carts on your pages is off, its row says recording is off: switch it back on in Site settings > Site access (see The two switches).

The same times are in Get a site's storefront activity (lastStorefrontOrderAt, lastStorefrontAddAt) and the MCP tool get_storefront_activity.

How the tag status sees a Google Tag Manager install

The tag status on the Install the tag card comes from an hourly check of your homepage. It does not run JavaScript: it looks for your site key in the HTML your server sends and, when that page loads a GTM container from www.googletagmanager.com, in that container's script, where the Main Tag keeps your key. The key appears there once the container is published: a tag that only exists in your workspace shows in Preview, not in the check. A container served from your own domain (server-side tagging) is not read, so the status reads Cannot verify. See How the check works.

After you rotate the site key

Rotate key on the Site key card stops the old key at once, so the Main Tag stops working until it carries the new one. In GTM, open your Main Tag, replace the Site public key with the new key shown on the Site key card, save, then submit and publish the container.

A Main Tag template downloaded after the rotation carries the new key, but importing it only fills in the key of the tags you create from it afterwards. A tag you already saved keeps the key it was saved with until you edit it.

The Sales tag carries no key: it needs no change.

Troubleshooting

Without Google Tag Manager

Paste the install snippet and call the transaction and addToCart commands in your store's templates. See Install without Google Tag Manager.