Ad Serving API

Ad Previews

The monetization framework supports the _bsa_url_preview parameter so you can preview ad creatives on your live site and share with clients for approval. If you are not leveraging the Monetization Framework there is some additional work that you will need to do in order to support this functionality.

Here is an example of parsing the value in JavaScript and storing the data in an options.testData variable.

const currentUrl = new URL(window.location.href)
const forceUrlPreview = currentUrl.searchParams.get('_bsa_url_preview')

if (forceUrlPreview) {
	const options = {}
	options.testMode = true
	const previewData = JSON.parse(forceUrlPreview)
	options.testData = previewData
	console.table(options.testData)
}

Update your code to check for the value of options.testMode and if it's true, you want to pass the value of options.testData into the function that displays the ad unit.

if (options.testMode) {
	// assign the value to the function that displays the ads
} else {
	// fetch the ad serving API and uses the value to display the ads
}

Feel free to modify the code above to fit into the framework and programming language you use. The general rule is to accept the _bsa_url_preview parameter and parse the JSON into the value that you can use to render the ads.