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):
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:
ptag extracts the token from the href to identify the ad.
How it works¶
- Extracts
tokenfrom<a href>inside the element to identify the ad - At
viewable, extracts and fires beacon URLs from redirect params:view_urlandthrad_view_url(when present) - Attaches an
IntersectionObserverto the element - Sends events when visibility changes