You can use a shortcode to get a single category name:
[adinserter data='category-n']
or single category slug:
[adinserter data='category-slug-n']
https://adinserter.pro/documentation/manual-insertion#shortcodes
I’ll consider adding support to generate all shortcodes with single quotes for direct insertion.
Thanks – I’ve already got this working with a single category – but that doesn’t help when there are multiple categories associated with a post. As a current example, we have a client who wants to target all articles from the area “crowthorne”. We do categorise articles with local place names.
An example article has the following categories:
featured
news
crowthorne
But if a visitor is looking at the story in say the “news” section the category picked up for .setTargeting would just be : googletag.pubads().setTargeting(‘category’, [‘news′]);
So even though the article has a category of “crowthorne” assigned as well as “news” then “crowthorne” doesn’t get passed to GAM for it to be targeted with an ad.
So being able pass categories in they way Google Ad Manager needs them would be fantastic.
Currently trying to figure this out with custom code – but a native shortcode in AdInserter would be fantastic!
Hope this all makes sense!
You can try the latest development version:
https://downloads.wordpress.org/plugin/ad-inserter.zip
Addes support for
[adinserter data='categories-single-quotes']
and
[adinserter data='categories-double-quotes']
So you should use:
googletag.pubads().setTargeting('category', [[adinserter data='categories-single-quotes']]);
Works a treat – I can stop pulling my hair out trying to custom code this now!
Thanks
Stuart
Does this work with custom taxonomies?