Skip to content
Browse the docs

GTM and pixel events

Spurn's tag publishes each paid click's verdict to the page, so Google Tag Manager and your own scripts can keep bots out of your remarketing lists and conversion data.

What the tag exposes#

When a paid landing loads, the tag reports it and Spurn answers with an instant verdict. The tag then does two things:

// 1. Pushes an event to the dataLayer
window.dataLayer.push({ event: 'spurn_verdict', spurn_verdict: 'invalid', spurn_score: 81 })

// 2. Sets the verdict on the page
window.spurn.verdict // 'invalid'
FieldValues
spurn_verdictvalid, suspicious, invalid or pending
spurn_score0 to 100

Three things to know:

  • It only happens on paid landings. On organic visits the tag does nothing, so there is no spurn_verdict event and no verdict on the page.
  • It is the instant verdict. Some clicks are clear at once, such as a known bot. Others come back as pending while Spurn waits for engagement. The final verdict, a few minutes later, appears in your dashboard but is not pushed to the page again.
  • It arrives after a network round trip. Tags that fire on page load have already fired by the time the event lands. The recipes below deal with that.

Treat pending as a real visitor. Holding back on pending would hold back genuine shoppers too.

Set up GTM#

Create the variables#

In Variables, create a Data Layer Variable:

  • Name: DLV - spurn_verdict
  • Data Layer Variable Name: spurn_verdict

Create a second one for spurn_score if you want to use the score.

Create the verdict trigger#

In Triggers, create a Custom Event trigger:

  • Name: Spurn verdict - not invalid
  • Event name: spurn_verdict
  • Fires on: Some Custom Events, where DLV - spurn_verdict does not equal invalid

Keep bots out of conversion and event tags#

For tags that fire on something the visitor does after the page loads, such as an add to cart, a form submission or a sign-up on the landing page, add one condition to the tag's existing trigger:

  • DLV - spurn_verdict does not equal invalid

Organic visitors pass, because the variable is empty for them. Paid visitors pass unless Spurn has flagged them.

Carry the verdict to later pages#

The dataLayer starts empty on every page load, so a tag on a later page, such as an order confirmation, cannot see the verdict from the landing page. Store it for the rest of the session yourself.

Add a Custom HTML tag that fires on the spurn_verdict Custom Event (any verdict):

<script>
  try {
    sessionStorage.setItem('spurn_verdict', {{DLV - spurn_verdict}});
  } catch (e) {}
</script>

Then create a Custom JavaScript variable, JS - spurn_verdict (session), that reads it back:

function () {
  try {
    return sessionStorage.getItem('spurn_verdict') || '';
  } catch (e) {
    return '';
  }
}

Use JS - spurn_verdict (session) does not equal invalid as the condition on tags that fire on later pages. Session storage is per browser tab and per domain, so this does not carry across to a checkout on a different domain.

Keep bots out of remarketing tags that fire on page load#

Remarketing tags usually fire on page view, before the verdict arrives. To hold them back on paid landings only, fire them from one of two triggers:

  1. Page View, not a paid landing. A Page View trigger where Page URL does not match RegEx (ignore case):

    [?&](gclid|gbraid|wbraid|gad_source|msclkid|ttclid|li_fat_id|twclid|epik|ScCid|sccid|rdt_cid)=|[?&]utm_medium=(cpc|ppc|paid|paidsearch|paid_search|paid-search|paidsocial|paid_social|paid-social|cpm|cpv|display|shopping|ads)(&|$)
  2. Spurn verdict - not invalid, the Custom Event trigger from above.

Add both triggers to the tag, and set its Tag firing options to Once per page. On ordinary pages the tag fires on page view as before. On paid landings it waits for Spurn's answer and fires unless the visitor is invalid.

The RegEx mirrors the parameters Spurn treats as paid. It leaves out fbclid on purpose, because Meta adds fbclid to organic shares too. Give your Meta ads a paid utm_medium, such as paid_social, so their landings match.

One trade-off: if the visitor's browser blocks Spurn's tag, the verdict never arrives, and the tag does not fire on that paid landing. If you would rather never miss a real visitor, use only the conversion and event recipe above.

Use the verdict in your own code#

window.spurn.verdict is set once Spurn's answer arrives. Read it in code that runs later, such as a click or submit handler:

document.querySelector('#signup-form').addEventListener('submit', function () {
  var verdict = window.spurn && window.spurn.verdict;
  if (verdict === 'invalid') return;
  // send your own lead or conversion event here
});

Meta and Microsoft events#

When Spurn's answer asks for it, the tag also fires an event into the ad pixels already on your page:

PlatformWhat the tag firesNeeds
Metafbq('trackCustom', 'SpurnInvalidTraffic')The Meta pixel (fbq) on the page
Microsoftuetq.push('event', 'spurn_invalid', {})The Microsoft UET tag (uetq) on the page

The answer asks for these events for visitors Spurn has flagged on a site where that platform is set up for protection. If the pixel is not on the page, nothing fires.

Microsoft. The spurn_invalid event is how flagged visitors reach your Microsoft exclusion audience. Spurn creates a remarketing list from that custom event and attaches it to your campaigns as a negative audience. Without the UET tag on your store, the list stays empty. See the Microsoft Ads guide.

Meta. Spurn's own Meta exclusion audience (Growth plan and up) is fed from Spurn's servers, not from this browser event. Spurn sends an InvalidTraffic event through the Conversions API to the pixel you choose, with the visitor's IP address, user agent and Meta browser ids, and builds the audience from it. The browser event SpurnInvalidTraffic is there for you: in Meta Ads Manager you can build your own website custom audience from it and exclude it wherever you choose, including ad accounts Spurn does not manage. See the Meta Ads guide.

Never use SpurnInvalidTraffic, InvalidTraffic or spurn_invalid as a conversion goal or optimisation event. They mark the traffic you want less of.