SDK Documentation

Pixel Installation

Install the Adverfly tracking pixel on your website

The Adverfly Pixel is a JavaScript snippet that tracks user interactions on your website. It captures pageviews, events, and conversions to power your analytics.

Quick Start

Add the following code to the <head> section of your website:

Request
<script>
  window.adverfly = window.adverfly || [];
  function advPxl() {
    var args = [false];
    for (var i = 0; i < arguments.length; i++) {
      args.push(arguments[i]);
    }
    adverfly.push(args);
  }
  advPxl("init", YOUR_WORKSPACE_ID);
  window.adverfly.store_currency = "EUR";
  window.adverfly.store_timezone = "Europe/Berlin";

  var script = document.createElement("script");
  script.type = "text/javascript";
  script.async = true;
  script.src = "https://sos-de-fra-1.exo.io/adv/advv2.01.js";
  document.getElementsByTagName("head")[0].appendChild(script);
</script>

Replace YOUR_WORKSPACE_ID with your Workspace ID from the Adverfly dashboard.

Configuration

ParameterTypeRequiredDescription
workspace_idnumberRequiredYour Adverfly Workspace ID
store_currencystringRequiredYour store's base currency (e.g., EUR, USD)
store_timezonestringRequiredYour store's timezone (e.g., Europe/Berlin)

Currency Conversion

The store_currency setting is important for accurate revenue tracking. If a transaction comes in with a different currency (e.g., a customer pays in USD), Adverfly automatically converts it to your store currency using the current exchange rate.

Example: Your store currency is EUR. A customer pays $129 USD. Adverfly converts this to ~€119 EUR in your reports.

Timezone

The store_timezone ensures all events and conversions are recorded in your local time, making your reports easier to read and analyze.

Tracking Events

Track custom events with the Adverfly Pixel

Once the pixel is installed, you can track custom events to capture user interactions.

Basic Event Tracking

Use the advPxl function to track events:

Request
// Add to Cart
advPxl("event", "add_to_cart");

// Initiated Checkout
advPxl("event", "initiated_checkout");

Standard Events

CodeDescription
pageviewUser views a page (tracked automatically on init)
add_to_cartUser adds item to cart
initiated_checkoutUser starts checkout process

Tracking Conversions

Track purchase and lead conversions

Conversions are the most important events to track. They represent completed goals like purchases or lead submissions.

Purchase Conversion

Track when a user completes a purchase:

Request
advPxl("conversion", "purchase", {
  transaction_id: "order123",              // required
  transaction_gross_revenue: 10999,        // required (in cents)
  transaction_currency: "EUR",             // required
  transaction_shipping_costs: 499,         // optional (in cents)
  transaction_tax: 1900,                   // optional (in cents)
  transaction_city: "Berlin",              // optional
  transaction_country_code: "DE",          // optional
  transaction_discount_code: "SUMMER20",   // optional
  customer_id: "customer@email.com",       // optional
  is_new_customer: 1,                       // optional (1 = new, 0 = returning)
});

Conversion Parameters

ParameterTypeRequiredDescription
transaction_idstringRequiredUnique order ID
transaction_gross_revenuenumberRequiredTotal revenue in cents (e.g., 10999 = €109.99)
transaction_currencystringRequiredCurrency code (EUR, USD, etc.)
transaction_shipping_costsnumberOptionalShipping costs in cents
transaction_taxnumberOptionalTax amount in cents
transaction_citystringOptionalCustomer's city
transaction_country_codestringOptionalISO country code (DE, US, etc.)
transaction_discount_codestringOptionalApplied discount/coupon code
customer_idstringOptionalCustomer identifier (e.g., email)
is_new_customernumberOptional1 = new customer, 0 = returning

With Line Items

You can also pass individual line items:

Request
advPxl("conversion", "purchase", {
  transaction_id: "order123",
  transaction_gross_revenue: 2000,
  transaction_currency: "EUR",
  transaction_shipping_costs: 350,
  transaction_tax: 150,
  transaction_city: "Berlin",
  transaction_country_code: "DE",
  customer_id: "customer@email.com",
  is_new_customer: 1,
  transaction_items: [
    {
      transaction_item_id: "123",
      transaction_item_name: "Product 1",
      transaction_item_price: 1000,
      transaction_item_tax: 50,
      transaction_item_quantity: 2,
    },
    {
      transaction_item_id: "124",
      transaction_item_name: "Product 2",
      transaction_item_price: 500,
      transaction_item_quantity: 1,
    },
  ],
});

Item Parameters

ParameterTypeRequiredDescription
transaction_item_idstringRequiredProduct/SKU ID
transaction_item_namestringRequiredProduct name
transaction_item_pricenumberRequiredItem price in cents
transaction_item_quantitynumberRequiredQuantity purchased
transaction_item_taxnumberOptionalItem tax in cents

Lead Conversion

Track when a user submits a lead form:

Request
advPxl("conversion", "lead", {
  transaction_id: "lead-456",
});

Google Tag Manager

Install Adverfly via Google Tag Manager

You can install the Adverfly Pixel using Google Tag Manager for easier management.

Installation Steps

  1. Open your GTM container
  2. Create a new Tag
  3. Choose Custom HTML
  4. Paste the following code:
Request
<script>
  window.adverfly = window.adverfly || [];
  function advPxl() {
    var args = [false];
    for (var i = 0; i < arguments.length; i++) {
      args.push(arguments[i]);
    }
    adverfly.push(args);
  }
  advPxl("init", YOUR_WORKSPACE_ID);
  window.adverfly.store_currency = "EUR";
  window.adverfly.store_timezone = "Europe/Berlin";

  var script = document.createElement("script");
  script.type = "text/javascript";
  script.async = true;
  script.src = "https://sos-de-fra-1.exo.io/adv/advv2.01.js";
  document.getElementsByTagName("head")[0].appendChild(script);
</script>
  1. Set the trigger to All Pages
  2. Save and publish

Configuration

CodeDescription
store_currencyYour store's base currency. Transactions in other currencies are auto-converted.
store_timezoneYour store's timezone for accurate event timestamps in reports.

Tracking Conversions via Data Layer

If you're using the Data Layer for e-commerce events:

Request
<script>
  // This tag should fire on the purchase confirmation page
  advPxl("conversion", "purchase", {
    transaction_id: {{DL - Transaction ID}},
    transaction_gross_revenue: {{DL - Revenue}} * 100,
    transaction_currency: {{DL - Currency}}
  });
</script>

Tracking Custom Events

Create additional tags for custom events:

Request
<script>
  // Add to Cart tag - trigger on add_to_cart event
  advPxl("event", "add_to_cart");
</script>
Request
<script>
  // Initiated Checkout tag - trigger on checkout start
  advPxl("event", "initiated_checkout");
</script>
CodeDescription
Base PixelAll Pages
Purchase Conversionpurchase event / thank you page
Add to Cartadd_to_cart event
Initiated Checkoutinitiated_checkout event

Shopify Integration

Install Adverfly on your Shopify store

Adverfly integrates natively with Shopify's Customer Events API for accurate tracking.

Installation Steps

  1. Go to your Shopify Admin
  2. Navigate to SettingsCustomer events
  3. Click Add custom pixel
  4. Name it "Adverfly"
  5. Paste the following code:
Request
const script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
script.src = "https://sos-de-fra-1.exo.io/adv/script-shopify.js";
document.getElementsByTagName("script")[0].parentNode.appendChild(script);

window.adverfly_web_pixel = true;
window.adverfly_init = init;
window.adverfly_browser = browser;
window.adverfly_settings = api.settings;

window.adverfly = window.adverfly || [];
window.advPxl = function () {
  adverfly.push([false, ...arguments]);
};

analytics.subscribe("all_events", (event) => {
  window.adverfly.push(["all_shopify_events", event]);
  advPxl("init", YOUR_WORKSPACE_ID);
  window.adverfly.store_currency = "EUR";
  window.adverfly.store_timezone = "Europe/Berlin";

  if (event.name === "page_viewed") {
    advPxl("check", "vikeys", event);
  }
});

Replace YOUR_WORKSPACE_ID with your Workspace ID and set your store's currency and timezone.

Configuration

CodeDescription
store_currencyYour store's base currency. Transactions in other currencies are auto-converted.
store_timezoneYour store's timezone for accurate event timestamps in reports.

Tracked Events

The Shopify integration automatically tracks all standard e-commerce events:

CodeDescription
page_viewed → pageviewShopify page_viewed event, recorded as pageview in Adverfly
product_added_to_cart → add_to_cartShopify add to cart event, recorded as add_to_cart in Adverfly
checkout_started → initiated_checkoutShopify checkout start, recorded as initiated_checkout in Adverfly
checkout_completed → purchaseShopify purchase event, recorded as purchase conversion in Adverfly

Surveys

Embed Adverfly surveys on your website

Embed Adverfly surveys directly on your website to collect customer feedback, post-purchase reviews, or NPS scores.

Quick Start

If you already have the Adverfly pixel installed, simply add this div where you want the survey to appear:

Request
<div data-adv-survey-id="SURVEY_ID" data-adv-workspace-id="WORKSPACE_ID"></div>

Replace SURVEY_ID with your survey ID and WORKSPACE_ID with your workspace ID (both found in the survey settings).

The pixel automatically detects survey embeds and renders them.

Parameters

ParameterTypeRequiredDescription
data-adv-survey-idstringRequiredYour survey ID
data-adv-workspace-idstringRequiredYour workspace ID
data-adv-survey-versionstringOptionalSpecific survey version (uses latest by default)
data-adv-order-idstringOptionalOrder/transaction ID to link survey responses to a specific purchase
data-adv-langstringOptionalLanguage code like de, fr, en, or default. Omitting it keeps the legacy English UI fallback.

Customer & Transaction Tracking

Survey events automatically include customer_id and transaction_id when set via the Adverfly Layer. This allows you to link survey responses to specific customers and orders.

Request
<script>
  window.adverfly = window.adverfly || [];
  function advPxl() { adverfly.push([!1, ...arguments]); }
  advPxl("init", WORKSPACE_ID);
  window.adverfly.store_currency = "EUR";
  window.adverfly.store_timezone = "Europe/Berlin";

  /* Set customer and transaction IDs */
  window.adverfly.customer_id = "customer_123";
  window.adverfly.transaction_id = "order_456";
</script>

Adverfly Layer Properties

ParameterTypeRequiredDescription
window.adverfly.customer_idstringOptionalCustomer ID to associate with survey responses
window.adverfly.transaction_idstringOptionalTransaction/Order ID to link survey responses to purchases
window.adverfly.store_currencystringOptionalStore currency (e.g., EUR, USD)
window.adverfly.store_timezonestringOptionalStore timezone (e.g., Europe/Berlin)

These properties are automatically included in all survey events (survey_opened, survey_answer, survey_completed).

Multi-Language Support

Surveys support multiple languages. Set data-adv-lang to display translated content. Use default to force the survey base content while keeping the UI fallback in English:

Request
<div
  data-adv-survey-id="SURVEY_ID"
  data-adv-workspace-id="WORKSPACE_ID"
  data-adv-lang="de"
></div>
CodeDescription
defaultBase survey content with English UI fallback
enEnglish UI, and translations.en if configured
deGerman
frFrench (if configured)

If data-adv-lang is omitted entirely, the public embed keeps the legacy behavior: English UI with the survey base content. Translations must be configured in the survey settings within Adverfly.

Survey Features

  • Required questions: Questions marked as required show a red asterisk (*) and validate before proceeding
  • Multi-step navigation: Surveys display one question at a time with Back/Next buttons
  • Progress indicator: Shows current step and progress bar
  • Thank you screen: Customizable message after submission

Survey Requirements

For the embed to work, your survey must:

  • Be set to live status
  • Have the Adverfly v2 pixel installed on the page (surveys are not supported in the v1 pixel)

Survey Events

The pixel automatically tracks these events for analytics:

CodeDescription
survey_openedFired when survey is displayed to user
survey_answerFired for each question answered
survey_completedFired when user submits the survey

All events include form_id, submission_id, and (if set) customer_id and transaction_id.