Microsoft KB Archive/326028

= INFO: Targeting an Ad to a Page Group =

Article ID: 326028

Article Last Modified on 10/22/2003

-

APPLIES TO


 * Microsoft Commerce Server 2.0
 * Microsoft Commerce Server 2000 Standard Edition

-



This article was previously published under Q326028





SUMMARY
For information about how to target page groups for advertisements, the Commerce Server online books refer you to the Ad Sitelet sample:

&quot;Before you can target an ad to a page group, your site developer must ad-enable the page. To ad-enable a page, see the Ad Sitelet sample in the Commerce Server 2000 Software Development Kit.&quot;

To ad-enable pages means to define how the GetAdContent function is called. The GetAdContent function is in the site code (not in the documentation) at the following location:

\Inetpub\wwwroot\adsitelet\include\advertlib.asp

The first parameter of the GetAdContent function is empty; the second parameter controls which page groups are used: set 1stAds = GetAdContent(empty, page_group_name, 1)

Adding Page Groups
You use page groups to specify the pages on which your ads appear on your Web site. Using page groups, you can place targeted ads on all pages of your commerce site, or on only one particular page if you want. For example, a News site might have a Sports page group to which you would target sports-related ads. Additionally, you can charge advertisers different rates based on the page group on which they advertise. Page groups are validated using the Page Groups section in the Reference Tables module.

The page groups in the reference tables are available when you select the page on which you want a campaign item to appear. After the page group that is used by the campaign item is validated against the Page Group property, the campaign item can be put into production. You can view a list of all current page groups, you can add new page groups, edit page groups, and delete page groups from the Page Group section in the Reference Tables module.



Sample Code
'-- ' GetAdContent ' ' Description: '    Retrieves an HTML string corresponding to an ad or discount. Wraps '    the call to IContentSelector::GetContent ' ' Parameters: '    [in] oProfile - Optional. Profile object of the profile you want to '                    use for targeting. '    [in] strPageGroup - Optional. The name of the page group you are '                        requesting an ad for. '    [in] intAdsReq - Count of ads you want returned from the CSF. ' ' Returns: '    SimpleList - Ads selected by the CSF based on data provided. ' ' Notes: ' '-- Function GetAdContent( _   ByVal oProfile, _    ByVal strPageGroup, _    ByVal intAdsReq)

Dim oSelector Dim oCsfCtx Dim lstContent Dim strContent Set oCsfCtx = Application(&quot;CSFAdvertisingContext&quot;) Set oSelector = Server.CreateObject(&quot;Commerce.ContentSelector&quot;)

'You don't have to add a Profile Object to the ContentSelector object, however 'this is how we target a specific user. If (IsValid(oProfile, VALIDATE_OBJECT)) Then Set oSelector.UserProfile = oProfile End If 'You don't have to specify a page group, but it is one way to provide  'targeted content to your users. If (Not IsEmpty(strPageGroup)) Then oSelector.PageGroup = &quot;Home&quot; End If 'Requesting multiple ads at a time is faster than making multiple requests 'for just one ad. Again, you do not have to do this and default to requesting one. If (Not IsEmpty(intAdsReq)) Then oSelector.NumRequested = intAdsReq End If

'Pass the IContentSelector::GetContent method the Advertising Context 'stored in the application object. It will return a Commerce.SimpleList 'with elements for the maximum number of ads you requested. Set lstContent = oSelector.GetContent(oCsfCtx) 'Make sure you actually got a list of ads back If (IsValid(lstContent, VALIDATE_OBJECT)) Then Set GetAdContent = lstContent Else Set GetAdContent = Nothing End If

End Function

