DoubleClick अभियान सेवा

DoubleClick अभियान सेवा आपको Apps Script में FCM/DFA रिपोर्टिंग और ट्रैफ़िकिंग API का उपयोग करने की अनुमति देती है. यह एपीआई, प्रोग्राम के हिसाब से DoubleClick कैंपेन मैनेजर (डीसीएम) और DoubleClick डिजिटल मार्केटिंग (डीडीएम) रिपोर्टिंग का ऐक्सेस देता है.

रेफ़रंस

इस सेवा के बारे में विस्तृत जानकारी के लिए, डीसीएम/DFA रिपोर्टिंग और ट्रैफ़िकिंग API के लिए रेफ़रंस दस्तावेज़ देखें. Apps Script की सभी बेहतर सेवाओं की तरह ही, DoubleClick कैंपेन सेवा में भी उन ही ऑब्जेक्ट, तरीकों, और पैरामीटर का इस्तेमाल किया जाता है जो सार्वजनिक API के लिए किए जाते हैं. ज़्यादा जानकारी के लिए, हस्ताक्षर तय करने का तरीका लेख पढ़ें.

समस्याओं की रिपोर्ट करने और अन्य सहायता खोजने के लिए, DCM/DFA रिपोर्टिंग और ट्रैफ़िकिंग सहायता गाइड देखें.

नमूना कोड

नीचे दिए गए सैंपल कोड में, एपीआई के वर्शन 3.3 का इस्तेमाल किया गया है.

उपयोगकर्ता प्रोफ़ाइलों की सूची पाएं

यह सैंपल, खाते में उपलब्ध सभी उपयोगकर्ता प्रोफ़ाइलों को लॉग करता है.

advanced/doubleclick.gs
/**
 * Logs all of the user profiles available in the account.
 */
function listUserProfiles() {
  // Retrieve the list of available user profiles
  try {
    const profiles = DoubleClickCampaigns.UserProfiles.list();

    if (profiles.items) {
      // Print out the user ID and name of each
      for (let i = 0; i < profiles.items.length; i++) {
        const profile = profiles.items[i];
        console.log('Found profile with ID %s and name "%s".',
            profile.profileId, profile.userName);
      }
    }
  } catch (e) {
    // TODO (Developer) - Handle exception
    console.log('Failed with error: %s', e.error);
  }
}

चालू कैंपेन की सूची पाएं

यह सैंपल, सभी चालू कैंपेन के नाम और उनके आईडी लॉग करता है. पूरी सूची फिर से पाने के लिए, पेजिंग टोकन के इस्तेमाल पर ध्यान दें.

advanced/doubleclick.gs
/**
 * Logs names and ID's of all active campaigns.
 * Note the use of paging tokens to retrieve the whole list.
 */
function listActiveCampaigns() {
  const profileId = '1234567'; // Replace with your profile ID.
  const fields = 'nextPageToken,campaigns(id,name)';
  let result;
  let pageToken;
  try {
    do {
      result = DoubleClickCampaigns.Campaigns.list(profileId, {
        'archived': false,
        'fields': fields,
        'pageToken': pageToken
      });
      if (result.campaigns) {
        for (let i = 0; i < result.campaigns.length; i++) {
          const campaign = result.campaigns[i];
          console.log('Found campaign with ID %s and name "%s".',
              campaign.id, campaign.name);
        }
      }
      pageToken = result.nextPageToken;
    } while (pageToken);
  } catch (e) {
    // TODO (Developer) - Handle exception
    console.log('Failed with error: %s', e.error);
  }
}

नया विज्ञापन देने वाला और कैंपेन बनाना

यह सैंपल एक नया विज्ञापन देने वाला बनाता है और उस विज्ञापन देने वाले के साथ एक नया कैंपेन बनाता है. कैंपेन एक महीने तक चलने के लिए सेट है.

advanced/doubleclick.gs
/**
 * Creates a new advertiser, and creates a new campaign with that advertiser.
 * The campaign is set to last for one month.
 */
function createAdvertiserAndCampaign() {
  const profileId = '1234567'; // Replace with your profile ID.

  const advertiser = {
    name: 'Example Advertiser',
    status: 'APPROVED'
  };

  try {
    const advertiserId = DoubleClickCampaigns.Advertisers
        .insert(advertiser, profileId).id;

    const landingPage = {
      advertiserId: advertiserId,
      archived: false,
      name: 'Example landing page',
      url: 'https://www.google.com'
    };
    const landingPageId = DoubleClickCampaigns.AdvertiserLandingPages
        .insert(landingPage, profileId).id;

    const campaignStart = new Date();
    // End campaign after 1 month.
    const campaignEnd = new Date();
    campaignEnd.setMonth(campaignEnd.getMonth() + 1);

    const campaign = {
      advertiserId: advertiserId,
      defaultLandingPageId: landingPageId,
      name: 'Example campaign',
      startDate: Utilities.formatDate(campaignStart, 'GMT', 'yyyy-MM-dd'),
      endDate: Utilities.formatDate(campaignEnd, 'GMT', 'yyyy-MM-dd')
    };
    DoubleClickCampaigns.Campaigns.insert(campaign, profileId);
  } catch (e) {
    // TODO (Developer) - Handle exception
    console.log('Failed with error: %s', e.error);
  }
}