Skip to content

Setting up conversion tracking

The squarelovin conversion tracking code records purchases on your website, so you can see which sales your UGC and your creators generated.

You add the code to the thank-you or order confirmation page that customers see after a purchase. You can add it directly in your shop’s code (option A) or through Google Tag Manager (option B).

  • You know your subscription UUID. You find it in the embed codes in your stream settings, in the data-sq-sub attribute.
  • You can edit the template of your thank-you page (option A) or you have access to your Google Tag Manager container (option B).

Every setup has the same three parts:

  1. Global SDK code: loads the squarelovin library.
  2. Conversion data object (sq_conv): holds the order details.
  3. Conversion call: sends the data to squarelovin once the library has loaded.

Which option to choose:

Option A: Direct code Option B: Google Tag Manager
Best for Shops where you can edit the thank-you page template Shops that already use GTM with a GA4 e-commerce purchase event
Order data comes from Your shop template (filled in by the shop system) The existing dataLayer
Changes need A developer or template access Only GTM access

Option A: Direct setup on the thank-you page

Section titled “Option A: Direct setup on the thank-you page”
  1. Add the global SDK code. Add this script tag to your thank-you page and replace YOUR_SUBSCRIPTION_UUID with your subscription UUID:

    <script type="module" data-sq-sub="YOUR_SUBSCRIPTION_UUID" charset="utf-8"
    src="https://delivery-assets.squarelovin.com/sdk/squarelovin.min.js"></script>

    Include the script only once per page. If the SDK is already in the <head> of every page (for example for your widgets), skip this step and pass subuuid in the data object instead.

  2. Add the conversion data object. Fill sq_conv with the data of the current order. All fields are explained in The conversion data object.

    var sq_conv = {
    subuuid: 'YOUR_SUBSCRIPTION_UUID',
    oid: 'ORDER12345',
    price: 199.95,
    cur: 'EUR',
    dlang: 'en_us',
    products: [
    { product_id: 'product_1', price: 11.65, qty: 2 },
    { product_id: 'product_2', price: 5.27, qty: 1 }
    ],
    clid: 'CUSTOMER12345',
    coupon: 'SAVE20'
    };
  3. Send the conversion. Set SERVICE to 'ugc' for the UGC Manager or 'influencer' for the Creator Manager. If you use both products, call $sq.conversion once for each.

    var SERVICE = 'ugc';
    function sqSendConversion() {
    window.$sq.toggleTracker();
    window.$sq.conversion(SERVICE, sq_conv);
    }
    if (window.$sq) {
    sqSendConversion();
    } else {
    window.addEventListener('sq:load', sqSendConversion);
    }

    The window.$sq check matters: the sq:load event fires only once. If the SDK has already loaded, a plain event listener would wait forever and nothing would be tracked.

This option reads the order data from the GA4 e-commerce purchase event in your dataLayer. Check first that your shop sends this event on the thank-you page, with transaction_id, value, currency and items.

  1. Create the variable.

    • Go to Variables → User-Defined Variables → New.
    • Variable type: Data Layer Variable.
    • Data Layer Variable Name: ecommerce, Data Layer Version: Version 2.
    • Save it as DLV - ecommerce.
  2. Create the trigger.

    • Go to Triggers → New.
    • Trigger type: Custom Event.
    • Event name: purchase.
    • Save it as Event - purchase.
  3. Create the tag.

    • Go to Tags → New, tag type: Custom HTML.
    • Paste the code below and replace YOUR_SUBSCRIPTION_UUID. Set SERVICE to 'ugc' or 'influencer'.
    • Under Advanced Settings → Consent Settings, add the consent types your cookie banner uses for marketing or analytics.
    • Trigger: Event - purchase. Save and publish the container.

    The tag loads the SDK itself if it isn’t on the page yet.

    <script>
    (function () {
    var SUB = 'YOUR_SUBSCRIPTION_UUID';
    var SERVICE = 'ugc'; // 'influencer' for the Creator Manager
    var ec = {{DLV - ecommerce}} || {};
    var items = ec.items || [];
    var sq_conv = {
    subuuid: SUB,
    oid: String(ec.transaction_id || ''),
    price: Number(ec.value) || 0,
    cur: ec.currency || 'EUR',
    dlang: (document.documentElement.lang || 'en-us').toLowerCase().replace('-', '_'),
    coupon: ec.coupon || '',
    products: items.map(function (i) {
    return {
    product_id: String(i.item_id),
    price: Number(i.price) || 0,
    qty: Number(i.quantity) || 1
    };
    })
    };
    function send() {
    window.$sq.toggleTracker();
    window.$sq.conversion(SERVICE, sq_conv);
    }
    if (window.$sq) { send(); return; }
    window.addEventListener('sq:load', send);
    if (!document.querySelector('script[src*="delivery-assets.squarelovin.com/sdk"]')) {
    var s = document.createElement('script');
    s.type = 'module';
    s.charset = 'utf-8';
    s.src = 'https://delivery-assets.squarelovin.com/sdk/squarelovin.min.js';
    s.setAttribute('data-sq-sub', SUB);
    document.head.appendChild(s);
    }
    })();
    </script>
  • Product IDs must match. item_id in your dataLayer must be the same ID as in your squarelovin product feed.
  • Order total. Depending on the shop, GA4’s value includes or excludes shipping and tax. squarelovin expects the order total after discounts. Keep this definition the same everywhere.
  • Language. The tag reads the language from the page’s <html lang> attribute, for example de-DE becomes de_de. If your shop doesn’t set it, replace that line with a fixed value such as 'de_de'.
  • Test in Preview mode first and check that the tag fires on purchase (see Testing your setup).
Property Status Description
subuuid Recommended Your subscription UUID. If missing, the SDK reads it from data-sq-sub on the script tag. If neither is set, no conversion is sent and no error is shown.
oid Recommended Unique order ID. Helps match conversions to orders.
price Required Order total after discounts, as a number (199.95, not '199,95 €').
cur Required Currency code in ISO 4217 format, for example EUR, USD.
dlang Required Language code, for example de_de, en_us.
products Recommended Array of purchased products. Each entry has product_id (same ID as in your product feed), price (per item, after discounts) and qty (quantity).
clid Optional Unique customer ID, useful for recognizing returning customers.
coupon Optional Coupon code used for the purchase.

Legacy format pids: Older setups pass products as pids (product ID to price). This still works, but if products is set, pids is ignored. New setups should use products only.

pids: {
'product_1': 11.65,
'product_2': 5.27
}
  1. GTM only: Open Preview in Google Tag Manager and start a session on your shop.
  2. Place a test order or open the thank-you page in a private window.
  3. GTM only: In Tag Assistant, check that the squarelovin tag fired on the purchase event.
  4. Open the browser developer tools (F12) and check the Console tab for errors.
  5. Check the request. In the Network tab, filter for add-conversion. Status 200 means the conversion was sent. Click the request and check the values under Payload, especially price, cur and the product IDs.
Problem Solution
No add-conversion request in the Network tab Check that subuuid is in sq_conv or data-sq-sub is on the script tag. Without either, nothing is sent and no error is shown.
Code runs, but still no request Use the window.$sq check from option A, step 3. A plain sq:load listener misses the event if the SDK loaded first.
$sq is not defined The conversion code runs before the SDK has loaded. Wrap the call as shown in option A, step 3.
GTM tag doesn’t fire Check in Preview mode that the purchase event reaches the dataLayer and that the consent settings allow the tag.
Wrong amount Pass price as a number with a dot as the decimal separator, without a currency symbol.
Conversions without products The product IDs don’t match your squarelovin product feed. Compare product_id or item_id with the IDs in the feed.
Conversion counted twice Make sure the code doesn’t fire again when the thank-you page is reloaded, and always pass oid.
JavaScript errors in the console Fix errors from other scripts on the page. They can stop the conversion code from running.

Should I use option A or option B? Use Google Tag Manager if your shop already sends a GA4 purchase event with complete data. Otherwise, use the direct setup.

What happens if I leave out required fields such as price or cur? The conversion won’t be recorded correctly. Make sure all required fields are present and formatted correctly.

Does the code slow down my page? No. The SDK loads as a module and doesn’t block the page from rendering.

How do I track conversions in a single-page application (SPA)? Run the code from option A, step 3 when the customer reaches the confirmation state. Thanks to the window.$sq check, it also works without a full page reload. With GTM, make sure your SPA pushes the purchase event to the dataLayer.

Is conversion tracking GDPR compliant? squarelovin follows data protection regulations such as the GDPR. You are responsible for getting your users’ consent through your cookie banner. For the Creator Manager, the affiliate cookie is set only after consent has been given.