Skip to content

ptag Manual Integration

Setup (one-time, in <head>)

<script>
  window.ptag = window.ptag || function() { 
    (window.ptag.q = window.ptag.q || []).push(arguments); 
  };
  window.ptag.trackImpression = window.ptag.trackImpression || function() {};
</script>
<script async src="https://cdn.thrad.ai/ptag.min.js"></script>
<script>
  // Use your publisher/tag id here.
  ptag("config", "pub_001", {});
</script>

Track an ad

Add one line to your existing ad render code — pass the ad container element (e.g. .thrad-ad-container):

ptag.trackImpression(adContainer, { send_to: "pub_001" });

Pass the outermost container of the ad so viewability is measured on the full ad area.

Example:

function renderAd(adData) {
  const container = createAdElement(adData);  // your existing code
  parentNode.appendChild(container);           // your existing code

  ptag.trackImpression(container, { send_to: "pub_001" }); // ← add this line
}

If you already set ptag("config", "pub_001", {}), send_to is optional.


What gets tracked

Event When
rendered Immediately when you call trackImpression
in_view Ad enters viewport
viewable 50% visible for 1 second (IAB standard)
view_end Ad leaves viewport or page closes

Requirements

The ad element must contain an <a> tag with the redirect URL:

<a href="https://ssp.thrads.ai/api/v1/tracking/redirect?token=...">

ptag extracts the token from the href to identify the ad.


How it works

  1. Extracts token from <a href> inside the element to identify the ad
  2. At viewable, extracts and fires beacon URLs from redirect params: view_url and thrad_view_url (when present)
  3. Attaches an IntersectionObserver to the element
  4. Sends events when visibility changes