<aside> 💡 Understanding: This guide explains how to install Traffic Cop on measure mode. These instructions apply whether you have received a snippet directly from the platform or your support team.

</aside>

<aside> ❓ Looking for Block Mode Instructions? Use Installation SOP: Traffic Cop Block Mode for Ad Tech Vendors with In-house Script

</aside>

<aside> 👉 Action: Use this document to understand the possible outcomes and results of placing the Pubguru ad script in different places on the page and, alongside the publisher, find the sweet spot between page loading speed and ad loading speed.

</aside>

Setup

Dynamically Load the Traffic Cop Script

In your JS code, you need to dynamically load the Traffic Cop script (see the sample code below)

function loadTrafficCopScript() {
	// Load the Traffic Cop script
	var trafficCopScript = document.createElement('script');
	trafficCopScript.src = '//c.pubguru.net/pg.site-config.js'; // Replace with actual Traffic Cop script link
	trafficCopScript.async = true;
	// Append the Traffic Cop script to body
	document.body.appendChild(trafficCopScript);
}

🖊️ NOTE: Please insert the Traffic Cop script freely within your code, but ensure it's placed before any operations that could significantly delay page loading. This is crucial to allow early detection of invalid traffic which would otherwise be affected by premature blocking. Ideally, it should be loaded after your ad load calls and essential measurement/tracking APIs.

<aside> <img src="/icons/info-alternate_blue.svg" alt="/icons/info-alternate_blue.svg" width="40px" />

The actual code might look different depending on your script implementation. If you have any trouble loading the Traffic Cop script dynamically, reach out to your Traffic Cop POC.

</aside>

Appendix: Important Reminders

Speed & Async Loading

For maximum speed, Traffic Cop must run async. An asynchronous script won't block the main thread while waiting for external data. This means the user interface (UI) remains responsive, allowing users to interact with the page even while data is being fetched. As such, please do not remove the async attribute or replace it with defer.

Caching

Do not copy the contents, and host them in your script. Traffic Cop uses CloudFront, one of the top-performing CDNs on the planet. There is no need to host the content on your server or CDN as it will result in delayed publishing of updates.

Caching, minifying, or lazy-loading this script is also not advised, as it can interfere with any tech or machine learning updates being delivered. Cached, minified, or lazy-loaded versions might continue to serve the old script or lead to some unintended behavior.