I'm currently using DFP's key value targeting to allow flexibility for targeting ads to specific pages and page types. So for example the setTargeting function will be like this when the page loads
.setTargeting('Site_URL', ['/news/article']);
This implementation is for Desktop and Smartphone.
However for AMP pages it required the key-value be placed at the ad unit level like this.
<amp-ad width=320 height=100
type="doubleclick"
data-slot="/XXXXXXXX/amp_test"
data-json='{"targeting": {"Site_URL":["/news/article"]}}'>
<div placeholder></div>
<div fallback></div>
</amp-ad>
Now what i want is to be able to set the "/news/article" (value) part dynamically just as i do on desktop and smartphone.
However on AMP pages JavaScript as you know doesn't really work and we have some complex code that dynamically sets these values on desktop and mobile.
I want to be able to generate this same key-value combination dynamically to the data json property.
Any idea how to go about this is greatly appreciated.
Late, but probaly the error goes because de "data-json" attr should be "json"
Check it
<amp-ad width=320 height=50
type="doubleclick"
data-slot="/4119129/mobile_ad_banner"
json='{"targeting":{"sport":["rugby","cricket"]},"categoryExclusions":["health"],"tagForChildDirectedTreatment":1}'>
</amp-ad>