openx ad serving issues with custom targeting parameters?

Author
Sade Osei Author
|
3 days ago Asked
|
15 Views
|
2 Replies
0

hey everyone, we're really scratching our heads over an OpenX custom targeting problem here. we're trying to leverage its advanced features for a new programmatic campaign, specifically around really granular audience segments.

the core issue is that while basic ad serving works perfectly fine, the custom targeting parameters we're defining within OpenX aren't consistently being passed or interpreted correctly by the invocation codes. this is leading to some pretty frustrating incorrect ad delivery where we expect one ad but get another.

we've set up several custom variables like user_segment, page_type, and content_category and associated them with specific zones. the invocation code on our pages definitely includes these parameters, but it seems like the OpenX ad server backend isn't always matching them to the correct campaigns or creatives. we've double-checked variable names, data types (string vs. integer), and the campaign targeting rules in the OpenX UI multiple times. everything looks correct.

for example, we expect ads targeted to user_segment=premium to show for those users, but sometimes we see default ads or even ads for user_segment=standard. it's like the parameter just gets dropped or misread, or something upstream is misinterpreting it. here's a simplified version of our invocation code snippet, maybe someone can spot something obvious I'm missing:

<script type='text/javascript'>
var ox_vars = {
    'zoneid': 12345,
    'user_segment': 'premium', // This is the one causing trouble
    'page_type': 'article'
};
document.write('<scr' + 'ipt type="text/javascript" src="https://ads.ourdomain.com/www/delivery/ajs.php?' + ox_vars.zoneid + '&user_segment=' + ox_vars.user_segment + '&page_type=' + ox_vars.page_type + '"></scr' + 'ipt>');
</script>

are there any common pitfalls with OpenX custom targeting, especially when constructing the invocation URL parameters? or specific debugging steps beyond checking the UI and the client-side code that could help ensure the OpenX ad server correctly processes these parameters from invocation codes, particularly with more complex programmatic ad serving logic? we're really trying to make sure our programmatic ad serving is as precise as possible.

thanks in advance!

2 Answers

0
Mei Tanaka
Answered 2 days ago
Hello Sade Osei, It sounds like you've been 'scratching your heads' quite a bit on this, and it's a common experience where the most obvious details become invisible after staring at code for hours. You've hit a very typical OpenX custom targeting challenge, and it's often rooted in how the invocation URL parameters are constructed and how OpenX expects them. Let's get straight to the technical issue in your provided invocation code snippet. You've correctly identified the need to pass `zoneid`, `user_segment`, and `page_type`. However, the way you're building the URL for `ajs.php` has a critical structural flaw for OpenX:
document.write('<scr' + 'ipt type="text/javascript" src="https://ads.ourdomain.com/www/delivery/ajs.php?' + ox_vars.zoneid + '&user_segment=' + ox_vars.user_segment + '&page_type=' + ox_vars.page_type + '"></scr' + 'ipt>');
The problem lies immediately after `ajs.php?`. You're appending `ox_vars.zoneid` directly without specifying the parameter name. OpenX expects a named parameter for the zone ID, typically `zoneid`. More importantly, for custom targeting variables, OpenX generally requires a `c_` prefix in the URL query string. Your corrected invocation code should look like this:
<script type='text/javascript'>
var ox_vars = {
    'zoneid': 12345,
    'user_segment': 'premium',
    'page_type': 'article'
};
document.write('<scr' + 'ipt type="text/javascript" src="https://ads.ourdomain.com/www/delivery/ajs.php?zoneid=' + ox_vars.zoneid + '&c_user_segment=' + encodeURIComponent(ox_vars.user_segment) + '&c_page_type=' + encodeURIComponent(ox_vars.page_type) + '"></scr' + 'ipt>');
</script>
Notice these key changes:
  1. ajs.php?zoneid=' + ox_vars.zoneid: The zoneid= parameter name is now explicitly included.
  2. &c_user_segment= and &c_page_type=: Custom variables in OpenX's `ajs.php` invocation require the c_ prefix. Without it, the ad server treats them as unrecognized or standard parameters, which won't map to your custom targeting rules.
  3. encodeURIComponent(): While not strictly required if your values are simple strings like 'premium', it's a best practice to URL-encode custom variable values, especially if they might contain spaces, ampersands, or other special characters. This prevents unintended URL breaks or misinterpretations.
Beyond this immediate fix, here are additional debugging steps and considerations for OpenX custom targeting and programmatic ad serving logic:

1. OpenX UI Configuration Double-Check:

  • Custom Field Definition: Ensure your custom variables (e.g., `user_segment`, `page_type`) are correctly defined in OpenX under "Configuration" -> "Custom Variables" (or similar path depending on your OpenX version). Verify their names and types (e.g., text, number).
  • Campaign/Creative Targeting Rules:
    • Exact Match: Confirm that the targeting rules for your campaigns and creatives precisely match the values you're passing. For example, if you target `user_segment` "Equals" "premium", ensure the passed value is exactly "premium" (case-sensitive).
    • Data Type Consistency: If you defined `user_segment` as a string, ensure you're not trying to match it as an integer in your targeting rules.
    • Operator: Pay attention to whether you're using "Equals," "Contains," "Starts with," etc. An "Equals" rule will fail if the passed value has any extra characters.
  • Campaign Priority & Weight: OpenX delivers ads based on a complex system of campaign priority, weight, and remaining impressions. If multiple campaigns could serve, an incorrect priority or weight could lead to a 'default' ad showing even if targeting matches for another. Review the delivery options and prioritization settings for conflicting campaigns.

2. Advanced Debugging Techniques:

  • Browser Developer Tools (Network Tab): This is your first line of defense. Open your browser's developer tools, go to the "Network" tab, and filter requests for `ajs.php`. Inspect the actual URL that your page makes to the OpenX ad server. This will show you exactly what parameters are being sent and if they're formatted correctly (e.g., `c_user_segment=premium`).
  • OpenX Debug Mode: Append `&ox_debug=true` to your page's URL (not the `ajs.php` URL) if your OpenX setup supports it. This can sometimes provide verbose output about ad selection logic directly on the page, showing why certain campaigns were considered or rejected.
  • Ad Server Access Logs (Self-Hosted): If you're running a self-hosted OpenX instance, delve into the web server's access logs (e.g., Apache `access_log`, Nginx `access.log`). Filter for requests to `ajs.php`. This will provide the definitive server-side view of the incoming URL parameters.
  • Isolated Test Pages: Create a very simple HTML page with just your OpenX invocation code and no other scripts or complex page content. Test different custom variable values on this page to isolate the problem from other client-side interactions.

3. Caching Considerations:

  • Browser Cache: Always perform a hard refresh (Ctrl+Shift+R or Cmd+Shift+R) or clear your browser cache when testing, as browser caching can sometimes serve old JavaScript or ad calls.
  • Server-Side Cache: If you have any caching layers (CDN, proxy, server-side caching) in front of your ad server or website, ensure they are configured correctly and not serving stale content that might affect the invocation code or the ad server's response.
By correcting the invocation URL structure and systematically reviewing your OpenX configuration and debugging with browser tools, you should be able to pinpoint why your programmatic ad serving isn't as precise as you need it to be.
0
Sade Osei
Answered 1 day ago

Yeah, Mei Tanaka, that was absolutely it! The `c_` prefix and explicitly adding `zoneid=`... so obvious once you pointed it out. This kind of detailed, spot-on help is exactly why I stick with forums, honestly.

Your Answer

You must Log In to post an answer and earn reputation.