This guide explains how to target ads on your website based on a blog post’s category in SoCast Engage. For example, if a visitor reads a post in the Morning Show category, you can display ads that sponsor the Morning Show.
To target ads by blog category, first define your ad slots and add your ad setup in the Ad Setup Code field.
Navigate to the Ad Setup Code field:
Website > Website Settings > Advertising
.Modify the Ad Setup Code:
Below is an example using the setTargeting
method. The %socast.blog.categories%
macro dynamically inserts the blog categories for targeting:
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot('/1234567/blog_category_targeted_ad', [300, 250], 'div-gpt-ad-123456789-0')
.setTargeting('category', %socast.blog.categories%) // Dynamically targets categories
.addService(googletag.pubads());
googletag.enableServices();
});
</script>
setTargeting
method passes the blog categories into ad targeting dynamically.category
) and the %socast.blog.categories%
macro.Next, add the slot you defined in the Ad Setup Code to the appropriate ad unit.
Open the Ad Units section:
Insert the slot code:
Here is an example for the Ad Units section:
<div id="div-gpt-ad-123456789-0" style="width: 300px; height: 250px;">
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-123456789-0'); });
</script>
</div>
After configuring your ad units in SoCast Engage, set up Google Ad Manager to target ads based on blog categories.
Log in to Google Ad Manager:
Create or edit a line item:
Set up custom targeting:
category
morning-show
, news
, entertainment
).Assign the line item to the ad unit: