First, you'll need to modify one of your regular ads to be targeted:
- Add the UserObject targeting context. For the user profile to be available for your targeting expressions, the context needs to be added in the marketing manager. Open the Marketing Manager, and choose the "Expressions" view in the left pane. Then click "Set Targeting Profiles" in the task list, and add the User Object (or whatever profile object represents your user profile) if it is not already present in the right-hand pane.
- Create your expression. Click "Create new target expression" in the list of tasks. Choose a name for your expression (123 area code), and build the expression ("UserObject.Telephone Number, Begins with, 123"). Click OK when you're done.
- Add the targeting expression to your ad. Open the ad you would like to target, and disapprove it if it is already approved. On the targeting tab, click Add in the "Targeting Expressions" section, and choose your new targeting expression. If you check "Create a Local Copy of this Global Expression", it will make a copy of the expression rather than link to the one you choose. This means that changes to the expression in the future won't affect your ad.
- Choose a targeting Action. You just added a condition to your ad. Now you need to specify whether your ad is only included where that condition is true ("Require"), or never shown if it's true ("Exclude"). These are just the simple choices; check MSDN for the full details.
- Save, Approve, and close the ad.
There you have it. Your targeted ad should now be worked into the set of ads returned by the ContentSelector based on the current user's profile. One more thing though, just in case: tracing. There is a trace mode for the ContentSelector, which you can use to see into the content selection process a bit. Its messages are quite cryptic, but it was useful for me to help troubleshoot why certain ads weren't showing. Here's some example code that will drop the trace messages into the page (borrowed from some Commerce Server boot camp training materials!):
ContentSelector cso = adSelector;
Response.Write(Environment.NewLine + Environment.NewLine + "<hr>");
Response.Write(Environment.NewLine + "<h2>cso Values</h2>");
Response.Write(Environment.NewLine + "ItemsRequested - '" + cso.ItemsRequested + "'<br/>");
Response.Write(Environment.NewLine + "Name - '" + cso.Name + "'<br/>");
Response.Write(Environment.NewLine + "PageHistory - '" + cso.PageHistory + "'<br/>");
Response.Write(Environment.NewLine + "Size - '" + cso.Size + "'<br/>");
Response.Write(Environment.NewLine + Environment.NewLine + "<h2>TraceMessages</h2>");
Response.Write(Environment.NewLine + "<table border=1>");
int i = 0;
foreach (StringCollection strcol in cso.TraceMessages)
{
Response.Write(Environment.NewLine + Environment.NewLine + "<tr><td>Item" + i + "</td><td>");
foreach (string s in strcol)
{
Response.Write(Environment.NewLine + s + "<br/>");
}
Response.Write(Environment.NewLine + "</td></tr>");
i++;
}
Response.Write(Environment.NewLine + "</table>");
No comments:
Post a Comment