Publisher Integration¶
Track viewability on placements.
Production script URL: https://cdn.thrad.ai/p.min.js.
Setup (one-time, in <head>)¶
<script>
window.p = window.p || function() {
(window.p.q = window.p.q || []).push(arguments);
};
window.p.observeAll = window.p.observeAll || function() { return { disconnect: function() {} }; };
</script>
<script async src="https://cdn.thrad.ai/p.min.js"></script>
<script>
p.observeAll('.content-slot');
</script>
Optionally set a stable tag id (if omitted, server derives one from the page URL):
Requirements¶
Placement container¶
Naming matters. Ad blockers scan CSS classes, element IDs, and function names in page source. Avoid words like
ad,banner,sponsored,tracker, orimpressionin your DOM — use neutral names such ascontent-slot,placement, orpromo-card.
The container must include an <a href="..."> with the redirect URL:
<div class="content-slot">
<a href="https://ssp.thrads.ai/api/v1/tracking/redirect?token=abc123">
<img src="creative.jpg" />
</a>
</div>
The tag extracts the token from the href to identify the placement (bid_id).
No extra data attributes needed.
What gets tracked¶
| Event | When |
|---|---|
rendered |
Element exists in DOM |
in_view |
Element enters viewport |
viewable |
50% visible for 1 second (IAB standard) |
view_end |
Element leaves viewport or page closes |
Options¶
p.observeAll('.content-slot', {
max: 10, // limit elements tracked (default 20)
sendOnInView: true, // send event when element enters viewport
sendOnViewable: true, // send event when element is viewable (50% for 1s)
sendOnViewEnd: true, // send event when element exits viewport
params: { // custom metadata for all events
placement_id: 'feed_top'
}
});
How it works¶
- Finds all matching elements by selector
- Tracks visibility via IntersectionObserver
- Sends events to backend
- Sends collect with
tag_idfromconfig(if omitted, server falls back tosite:<host>).
New elements added dynamically are auto-tracked.
Stop tracking¶
Google Tag Manager (GTM)¶
If you use GTM, you can install the publisher tag without touching your codebase:
- Go to GTM → Tags → New
- Choose Custom HTML
- Paste:
<script>
window.p = window.p || function() {
(window.p.q = window.p.q || []).push(arguments);
};
window.p.observeAll = window.p.observeAll || function() { return { disconnect: function() {} }; };
</script>
<script async src="https://cdn.thrad.ai/p.min.js"></script>
<script>
p.observeAll('.content-slot');
</script>
- Set trigger: DOM Ready
- Save and Publish
Same functionality, managed via GTM dashboard instead of code.