/// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

      Creative creative = new Creative();
      creative.AdvertiserId = advertiserId;
      creative.Name = "Test image creative";
      creative.Size = new Size() { Id = sizeId };
      creative.Type = "IMAGE";

      // Upload the image asset.
      CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
      CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "IMAGE");

      CreativeAsset imageAsset = new CreativeAsset();
      imageAsset.AssetIdentifier = imageAssetId;
      imageAsset.Role = "PRIMARY";

      // Add the creative assets.
      creative.CreativeAssets = new List<CreativeAsset>() { imageAsset };

      Creative result = service.Creatives.Insert(creative, profileId).Execute();

      // Display the new creative ID.
      Console.WriteLine("Image creative with ID {0} was created.", result.Id);
    }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string videoAssetName = _T("INSERT_VIDEO_ASSET_NAME_HERE");
              string pathToVideoAssetFile = _T("INSERT_PATH_TO_VIDEO_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test in-stream video creative";
              creative.Type = "INSTREAM_VIDEO";

              // Upload the video asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId videoAssetId = assetUtils.uploadAsset(pathToVideoAssetFile, "VIDEO");

              CreativeAsset videoAsset = new CreativeAsset();
              videoAsset.AssetIdentifier = videoAssetId;
              videoAsset.Role = "PARENT_VIDEO";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { videoAsset };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("In-stream video creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToHtmlAssetFile = _T("INSERT_PATH_TO_HTML_ASSET_FILE_HERE");
              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test enhanced banner creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "ENHANCED_BANNER";

              // Upload the HTML asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId htmlAssetId = assetUtils.uploadAsset(pathToHtmlAssetFile, "HTML");

              CreativeAsset htmlAsset = new CreativeAsset();
              htmlAsset.AssetIdentifier = htmlAssetId;
              htmlAsset.Role = "PRIMARY";
              htmlAsset.WindowMode = "TRANSPARENT";

              // Upload the backup image asset.
              CreativeAssetId backupImageAssetId =
              assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset backupImageAsset = new CreativeAsset();
              backupImageAsset.AssetIdentifier = backupImageAssetId;
              backupImageAsset.Role = "BACKUP_IMAGE";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { htmlAsset, backupImageAsset };

              // Configure the backup image.
              creative.BackupImageClickThroughUrl = "https://www.google.com";
              creative.BackupImageReportingLabel = "backup";
              creative.BackupImageTargetWindow = new TargetWindow() { TargetWindowOption = "NEW_WINDOW" };

              // Add a click tag.
              ClickTag clickTag = new ClickTag();
              clickTag.Name = "clickTag";
              clickTag.EventName = "exit";
              clickTag.Value = "https://www.google.com";
              creative.ClickTags = new List<ClickTag>() { clickTag };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("Enhanced banner creative with ID {0} was created.", result.Id);
        }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");
      string pathToImageAsset2File = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

      Creative creative = new Creative();
      creative.AdvertiserId = advertiserId;
      creative.AutoAdvanceImages = true;
      creative.Name = "Test enhanced image creative";
      creative.Size = new Size() { Id = sizeId };
      creative.Type = "ENHANCED_IMAGE";

      // Upload the first image asset.
      CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
      CreativeAssetId imageAsset1Id = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

      CreativeAsset imageAsset1 = new CreativeAsset();
      imageAsset1.AssetIdentifier = imageAsset1Id;
      imageAsset1.Role = "PRIMARY";

      // Upload the second image asset.
      CreativeAssetId imageAsset2Id = assetUtils.uploadAsset(pathToImageAsset2File, "HTML_IMAGE");

      CreativeAsset imageAsset2 = new CreativeAsset();
      imageAsset2.AssetIdentifier = imageAsset2Id;
      imageAsset2.Role = "PRIMARY";

      // Add the creative assets.
      creative.CreativeAssets = new List<CreativeAsset>() { imageAsset1, imageAsset2 };

      // Create a click tag for the first image asset.
      ClickTag clickTag1 = new ClickTag();
      clickTag1.Name = imageAsset1Id.Name;
      clickTag1.EventName = imageAsset1Id.Name;

      // Create a click tag for the second image asset.
      ClickTag clickTag2 = new ClickTag();
      clickTag2.Name = imageAsset2Id.Name;
      clickTag2.EventName = imageAsset2Id.Name;

      // Add the click tags.
      creative.ClickTags = new List<ClickTag>() { clickTag1, clickTag2 };

      Creative result = service.Creatives.Insert(creative, profileId).Execute();

      // Display the new creative ID.
      Console.WriteLine("Enhanced image creative with ID {0} was created.", result.Id);
    }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToHtml5AssetFile = _T("INSERT_PATH_TO_HTML5_ASSET_FILE_HERE");
              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test HTML5 banner creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "HTML5_BANNER";

              // Upload the HTML5 asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId html5AssetId = assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML");

              CreativeAsset html5Asset = new CreativeAsset();
              html5Asset.AssetIdentifier = html5AssetId;
              html5Asset.Role = "PRIMARY";

              // Upload the backup image asset.
              CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset imageAsset = new CreativeAsset();
              imageAsset.AssetIdentifier = imageAssetId;
              imageAsset.Role = "BACKUP_IMAGE";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { html5Asset, imageAsset };

              // Add a click tag.
              ClickTag clickTag = new ClickTag() { Name = "clickTag" };
              creative.ClickTags = new List<ClickTag>() { clickTag };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("HTML5 banner creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToFlashAssetFile = _T("INSERT_PATH_TO_FLASH_ASSET_FILE_HERE");
              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test flash in-page creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "FLASH_INPAGE";

              // Upload the flash asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId flashAssetId = assetUtils.uploadAsset(pathToFlashAssetFile, "FLASH");

              CreativeAsset flashAsset = new CreativeAsset();
              flashAsset.AssetIdentifier = flashAssetId;
              flashAsset.Role = "PRIMARY";
              flashAsset.WindowMode = "TRANSPARENT";

              // Upload the backup image asset.
              CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset imageAsset = new CreativeAsset();
              imageAsset.AssetIdentifier = imageAssetId;
              imageAsset.Role = "BACKUP_IMAGE";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { flashAsset, imageAsset };

              // Set the backup image target window option.
              creative.BackupImageTargetWindow = new TargetWindow() { TargetWindowOption = "NEW_WINDOW"};

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("Flash in-page creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToHtml5AssetFile = _T("INSERT_PATH_TO_HTML5_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            // Locate an advertiser landing page to use as a default.
            LandingPage defaultLandingPage = getAdvertiserLandingPage(service, profileId, advertiserId);

            // Create the creative structure.
            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test HTML5 display creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "DISPLAY";

            // Upload the HTML5 asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    html5AssetId =
                assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML").AssetIdentifier;

            CreativeAsset html5Asset = new CreativeAsset();

            html5Asset.AssetIdentifier = html5AssetId;
            html5Asset.Role            = "PRIMARY";

            // Upload the backup image asset.
            CreativeAssetId imageAssetId =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset = new CreativeAsset();

            imageAsset.AssetIdentifier = imageAssetId;
            imageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                html5Asset, imageAsset
            };

            // Configure the bacup image.
            creative.BackupImageClickThroughUrl = new CreativeClickThroughUrl()
            {
                LandingPageId = defaultLandingPage.Id
            };
            creative.BackupImageReportingLabel = "backup";
            creative.BackupImageTargetWindow   = new TargetWindow()
            {
                TargetWindowOption = "NEW_WINDOW"
            };

            // Add a click tag.
            ClickTag clickTag = new ClickTag();

            clickTag.Name            = "clickTag";
            clickTag.EventName       = "exit";
            clickTag.ClickThroughUrl = new CreativeClickThroughUrl()
            {
                LandingPageId = defaultLandingPage.Id
            };
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("HTML5 display creative with ID {0} was created.", result.Id);
        }
Пример #8
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToImageAssetFile  = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");
            string pathToImageAsset2File = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId      = advertiserId;
            creative.AutoAdvanceImages = true;
            creative.Name = "Test display image gallery creative";
            creative.Size = new Size()
            {
                Id = sizeId
            };
            creative.Type = "DISPLAY_IMAGE_GALLERY";

            // Upload the first image asset.
            CreativeAssetUtils assetUtils    = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    imageAsset1Id =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset1 = new CreativeAsset();

            imageAsset1.AssetIdentifier = imageAsset1Id;
            imageAsset1.Role            = "PRIMARY";

            // Upload the second image asset.
            CreativeAssetId imageAsset2Id =
                assetUtils.uploadAsset(pathToImageAsset2File, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset2 = new CreativeAsset();

            imageAsset2.AssetIdentifier = imageAsset2Id;
            imageAsset2.Role            = "PRIMARY";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                imageAsset1, imageAsset2
            };

            // Create a click tag for the first image asset.
            ClickTag clickTag1 = new ClickTag();

            clickTag1.Name      = imageAsset1Id.Name;
            clickTag1.EventName = imageAsset1Id.Name;

            // Create a click tag for the second image asset.
            ClickTag clickTag2 = new ClickTag();

            clickTag2.Name      = imageAsset2Id.Name;
            clickTag2.EventName = imageAsset2Id.Name;

            // Add the click tags.
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag1, clickTag2
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Display image gallery creative with ID {0} was created.", result.Id);
        }
Пример #9
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long instreamVideoCreativeId = long.Parse(_T("INSERT_INSTREAM_VIDEO_CREATIVE_ID_HERE"));
            long targetingTemplateId     = long.Parse(_T("INSERT_TARGETING_TEMPLATE_ID_HERE"));
            long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string videoAssetName       = _T("INSERT_VIDEO_ASSET_NAME_HERE");
            string pathToVideoAssetFile = _T("INSERT_PATH_TO_VIDEO_ASSET_FILE_HERE");

            // Retrieve the specified creative.
            Creative creative = service.Creatives.Get(profileId, instreamVideoCreativeId).Execute();

            if (creative == null || !"INSTREAM_VIDEO".Equals(creative.Type))
            {
                Console.Error.WriteLine("Invalid creative specified.");
                return;
            }

            CreativeAssetSelection selection = creative.CreativeAssetSelection;

            if (!creative.DynamicAssetSelection.Value)
            {
                // Locate an existing video asset to use as a default.
                // This example uses the first PARENT_VIDEO asset found.
                CreativeAsset defaultAsset =
                    creative.CreativeAssets.First(asset => "PARENT_VIDEO".Equals(asset.Role));
                if (defaultAsset == null)
                {
                    Console.Error.WriteLine("Default video asset could not be found.");
                    return;
                }

                // Create a new selection using the existing asset as a default.
                selection = new CreativeAssetSelection();
                selection.DefaultAssetId = defaultAsset.Id;
                selection.Rules          = new List <Rule>();

                // Enable dynamic asset selection for the creative.
                creative.DynamicAssetSelection  = true;
                creative.CreativeAssetSelection = selection;
            }

            // Upload the new video asset and add it to the creative.
            CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId,
                                                                   creative.AdvertiserId.Value);
            CreativeAssetMetadata videoMetadata = assetUtils.uploadAsset(pathToVideoAssetFile, "VIDEO");

            creative.CreativeAssets.Add(new CreativeAsset()
            {
                AssetIdentifier = videoMetadata.AssetIdentifier,
                Role            = "PARENT_VIDEO"
            });

            // Create a rule targeting the new video asset and add it to the selection.
            Rule rule = new Rule();

            rule.AssetId             = videoMetadata.Id;
            rule.Name                = "Test rule for asset " + videoMetadata.Id;
            rule.TargetingTemplateId = targetingTemplateId;
            selection.Rules.Add(rule);

            // Update the creative.
            Creative result = service.Creatives.Update(creative, profileId).Execute();

            Console.WriteLine("Dynamic asset selection enabled for creative with ID {0}.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToHtmlAssetFile  = _T("INSERT_PATH_TO_HTML_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test enhanced banner creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "ENHANCED_BANNER";

            // Upload the HTML asset.
            CreativeAssetUtils assetUtils  = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    htmlAssetId = assetUtils.uploadAsset(pathToHtmlAssetFile, "HTML");

            CreativeAsset htmlAsset = new CreativeAsset();

            htmlAsset.AssetIdentifier = htmlAssetId;
            htmlAsset.Role            = "PRIMARY";
            htmlAsset.WindowMode      = "TRANSPARENT";

            // Upload the backup image asset.
            CreativeAssetId backupImageAssetId =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

            CreativeAsset backupImageAsset = new CreativeAsset();

            backupImageAsset.AssetIdentifier = backupImageAssetId;
            backupImageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                htmlAsset, backupImageAsset
            };

            // Configure the backup image.
            creative.BackupImageClickThroughUrl = "https://www.google.com";
            creative.BackupImageReportingLabel  = "backup";
            creative.BackupImageTargetWindow    = new TargetWindow()
            {
                TargetWindowOption = "NEW_WINDOW"
            };

            // Add a click tag.
            ClickTag clickTag = new ClickTag();

            clickTag.Name      = "clickTag";
            clickTag.EventName = "exit";
            clickTag.Value     = "https://www.google.com";
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Enhanced banner creative with ID {0} was created.", result.Id);
        }