Create DSP Creative

The attached (downloadable) Zip file contains 8 code snippets demonstrating how to create DSP creatives and populate those creatives using Native (Gemini) ad assets.

You can download all 8 code snippets by clicking Create DSP Creative Java code snippets.

For reference, in the DSP API a creative is an object that defines the image or video asset that is the foundation of an ad. A single creative may be used in many different ads. Every ad is defined by a creative, which is identified by its creativeId.

Java Code Snippets

Follow this coding sequence when creating DSP creatives and populating those creatives with Gemini ad assets:

1.````. Begin like this:

// First call the Gemini API to get the Gemini ad payload
// GET{adId}
GeminiAd geminiAd = getGeminiAd(adId);

// Then map the Gemini ad to the DSP creative
DspCreative dspCreative = geminiAdToDspCreative(geminiAd);

// Now map the Gemini ad assets to the DSP creative
for (GeminiAdAsset geminiAdAsset : geminiAd.getAdAssets()) {
    populateDspCreativeFromGeminiAsset(dspCreative, geminiAdAsset);

// Here you call the DSP API to create the creative
// POST /traffic/creatives

2.````. Use this snippet to populate the DSP creative using Gemini ad. 3.````. Use this to populate the DSP creative using Gemini ad assets. It calls functions 4.1-4.5 using an if else condition. 4.1.```` 4.2.```` 4.3.```` 4.4.```` 4.5.````


Java code


Example 1

Shows a class that represents a Gemini targeting attribute.

Example 2

Defines enumerations to represent Gemini targeting types, which include DEVICE, DAY_TIME, LOCATION, AGE, GENDER, and SEGMENT.