Tapper
Search docs...
⌘K
SupportDashboard

Conversion script

Install the conversion script on your confirmation page to record each conversion with its order value, currency and order id.


The Conversion script records a conversion, with its order value, currency and order id, when it happens. Put it on your confirmation page only: it records a conversion every time it runs, so a copy on every page records a conversion on every page view.

If your tag manager cannot fire a tag on the confirmation page alone, do not install this script. Use Conversion pages instead: you list the pages that mean a conversion, turn on Count conversions only from these pages, and Tapper counts them from the monitoring script you already have.

Step 1: Pick your snippet

1
Open Setup > Website > Monitoring

In the sidebar, open Setup, then Website. If your workspace has more than one protected entity, first pick the one for this website with the switcher under the workspace name. In the list of areas on the left, click Monitoring, then open the Install script and consent tab.

2
Find the Conversion script section

The Conversion script section is below the monitoring script and the consent snippets. Your tracking ID is already in every snippet.

3
Pick the tab for your site

The section has four tabs. Pick the one that matches how your site is set up.

TabUse it for
Google Tag ManagerA Custom HTML tag in Google Tag Manager.
ShopifyA Shopify store. See Install the Tapper Shopify app.
PrestaShopA PrestaShop store.
JavaScriptTealium iQ, or a snippet you add to your confirmation page's HTML yourself.

Step 2: Add the script

The Google Tag Manager tab builds a Custom HTML tag that fires on your purchase trigger. The order value goes in a first block. If anything about it breaks, a second block still records a plain conversion.

1
Point the fields at your GTM variables

On the Google Tag Manager tab, type your own variable names into Order Value variable, Currency variable and Transaction ID variable. They start as {{DLV - ecommerce.value}}, {{DLV - ecommerce.currency}} and {{DLV - ecommerce.transaction_id}}. Type each variable's name exactly as it appears in the Name column of your Tag Manager Variables list, not the value in its Data Layer Variable Name field.

2
Check the optional fields

Currency is optional: clear it to use your ad account's currency. Transaction ID is optional and is used to avoid counting an order twice. If Order Value and Currency point at the same variable, Tapper warns you: Currency needs a 3-letter code such as USD, not an amount.

3
Copy the tag

Copy the snippet from the code box under the fields.

4
Create the tag in GTM

In GTM, open Tags, click New, choose Custom HTML as the tag type and paste the snippet into the HTML field.

5
Set the trigger

Select a trigger that fires on the confirmation page only, for example your purchase event or the thank-you page view. If the tag would fire on every page, use Conversion pages instead.

6
Save and publish

Give the tag a name you will recognize and click Save. Then click Submit, describe the changes, and click Publish.

If your GTM container is loaded through a Shopify customer-events pixel, use the Shopify tab instead. This tag does not work from inside a Shopify pixel.

Google Tag Manager without a data layer

If your site has no data layer with the order values, turn on My site has no dataLayer ecommerce variables on the Google Tag Manager tab of the Conversion script section. The tag then references no GTM variables at all and records a plain conversion, with no order value. If your container already has a Tapper conversion tag, replace it: running both records every purchase twice.

If the order total can be read anywhere on your thank-you page, leave the switch off instead. Create a Custom JavaScript variable in GTM that returns the order total as a number, and use its name in Order Value variable. The tab shows an example to start from.

Google Tag Manager with the Tapper template

You can use the Tapper conversion template from the GTM Community Template Gallery instead of the Custom HTML tag. It is named Tapper - Conversion Script.

  1. Add a tag from the template, or open your existing one.
  2. On a new tag, set Public Key (pk) to your Tapper public key. It is the value inside tapper.init("...") in your monitoring script. Without it the tag sends nothing.
  3. Map the template's three value fields to your data layer, as in the table below. Leave Currency empty to record the value in your ad account's currency. A store that sells in several currencies must map Currency.
  4. Keep your existing purchase trigger, then submit and publish the container.
Template fieldGTM variable to mapData layer path
Order Value{{DLV - ecommerce.value}} (Data Layer Variable).ecommerce.value
Currency (optional){{DLV - ecommerce.currency}} (Data Layer Variable).ecommerce.currency
Transaction ID (optional){{DLV - ecommerce.transaction_id}} (Data Layer Variable).ecommerce.transaction_id

With GA4 ecommerce tracking, these paths are already filled on the purchase event. Use each variable's name exactly as it appears in the Name column of your Variables list.

Step 3: Send the right values

The order value turns a conversion into a valued conversion. If you call the script yourself, the call is window.tapper.push(amount, currency, orderId), where currency and order id are optional.

  • Pass the amount as a real number (49.99), never as a string ("49.99").
  • Use a 3-letter currency code, for example USD. If you leave the currency out, the value is recorded in your connected ad account's currency.
  • A store that sells in several currencies must always pass a currency.
  • For an amount of exactly 1, always pass the currency.
// Order value only, recorded in your connected ad account's currency
window.tapper.push(49.99);
 
// Explicit currency (multi-currency stores must always pass one)
window.tapper.push(49.99, 'USD');
 
// With your order id
window.tapper.push(49.99, 'USD', 'ORD-1042');
 
// Always pass currency explicitly for amounts of exactly 1
window.tapper.push(1, 'USD');

Step 4: Verify

Use GTM's Preview mode to confirm the tag fires on your confirmation page, and only there.