GetAd Method

The GetAd method selects the most appropriate advertisement and returns HTML text that can be inserted into the calling page.

Syntax

AdServerObject.GetAd([Response], [TagList], [History])

Parameters

Response

Optional. The ASP-intrinsic Response object, required for logging ad impression events to the IIS log file. The log file is later used by Usage Analyst. If this argument is omitted, the method does not log the ad impression event to the log file.

TagList

Optional. An array of text strings that specify the types of ads to be served and  the way in which the ads are displayed on the page.

History

Optional. A string Variant that contains the user's advertisement viewing history. The string is a comma-separated list of the campaign item ids (ciids) of the ads that have already been selected for the current user. The string is usually persisted only for the duration of a user session.

Examples

The following example requests an ad from AdServer and enables it to record events for the returned ad to the IIS log file. 

<% =Ad.GetAd(Response) %>

The following example creates a tag list, then passes this list to the GetAd method to specify a preference for ads targeted at people interested in sports and living in the Northwest region.

<% Set Ad = Application("Ad") %>
<% Taglist = Array("PageGroup.Sports", "Region.Northwest") %>
<% =Ad.GetAd (Response, TagList ) %>

The following example retrieves the visitor’s history string from the Session object, and makes a request for an ad that takes into consideration the visitor’s history. The AdServer uses the history string to exclude overexposed ads, delivers an ad, and appends the newly delivered ad to the history string. The last line of the script then resets the history to include the latest ad.

  <% Dim HistoryString %>
  <% HistoryString = Session("HistoryString") %>
  <% = Ad.GetAd(Response, Null, HistoryString) %>
  <% Session("HistoryString") = HistoryString %> 

Remarks

In order for the GetAd method to log the impression event, you must set the logging properties for the Web site to enable URI Query.

If the ad being served can be clicked (that is, if the campaign item was specified as type IMG or BUYNOW in the Ad Manager), this method creates an HREF tag that includes the value of the RedirectURL property. For example, AdServer creates the following HREF tag for a clickable Trey Research ad on the Ad Samples default.asp page. The URL of the click-through page, in this case /adsamples/Trey.asp, which is passed as a parameter to the Adredir.asp page is set on the Campaign Item page in the Ad Manager.

<A HREF="/adsamples/adredir.asp?ciid=4&url=/adsamples/Trey.asp" TARGET=_top>

If the GetAd method cannot determine an appropriate ad, it returns the ad specified by the DefaultAd property. In this case, the RedirectURL property is not used.

See Also

RedirectURL, DefaultAd, Taglist Argument


© 1997-1998 Microsoft Corporation. All rights reserved.