protected override void PopulateAdManager() { base.PopulateAdManager(); // Register 1 BigBox ad AdUnits.Add(AdManagerModel.Register(AdType.BigBox)); }
protected virtual void PopulateAdManager() { // register first AD (leaderboard) AdUnits.Add(AdManagerModel.Register(AdType.Leaderboard)); AdManagerModel.AddSetting("site", "betterswing"); AdManagerModel.AddSetting("network", "test"); AdManagerModel.AddSetting("page", "show"); //AdSettings.KeyValuePairs.Add("section", "show"); //AdSettings.KeyValuePairs.Add("liveinsite", "show"); }
/// <summary> /// Placeholder that is replaced with ads. /// </summary> /// <param name="unitName">Name of the ad unit as set in DFP.</param> /// <param name="size">Specify creative sizes in the googletag.defineSlot() function. To allow multiple sizes to serve to the ad slot, you can use a comma-separated list.</param> /// <param name="cssClass">CSS class to add to the ad unit div container.</param> /// <param name="tagName">Type of parent container, must be block</param> /// <param name="sizeMapping">Specify creative sizes in the googletag.defineSlot() function. To allow multiple sizes to serve to the ad slot, you can use a comma-separated list.</param> /// <param name="display">Should display be called when the dfp script is initialised?</param> /// <param name="targeting">GA slot specific targeting</param> /// <returns>HTML container object.</returns> public static IHtmlString Placeholder(string unitName, string size, string cssClass, string tagName, string sizeMapping, bool display, Dictionary <string, string> targeting) { if (String.IsNullOrWhiteSpace(unitName)) { throw new ArgumentNullException("unitName"); } cssClass = cssClass ?? ""; tagName = tagName ?? "div"; targeting = targeting ?? new Dictionary <string, string>(); sizeMapping = sizeMapping ?? ""; if (String.IsNullOrWhiteSpace(tagName)) { throw new ArgumentNullException("tagName"); } var containerId = "div-gpt-ad-" + _adCounter; string placeholder = String.Format( CultureInfo.InvariantCulture, "<{0} id=\"{1}\" class=\"{2}\" data-cb-ad-id=\"{3}\"><!-- {3} --></{0}>", tagName, containerId, cssClass, unitName); var unit = new AdUnit { UnitName = unitName, Size = size, Display = display, Id = containerId, Targeting = targeting }; if (!string.IsNullOrWhiteSpace(sizeMapping)) { // Confirm the mapping exists if (!SizeUnits.ContainsKey(sizeMapping)) { throw new ArgumentException(String.Format("Size unit '{0}' not defined. Sizes must be defined before adding to a unit.", sizeMapping), "sizeMapping"); } unit.SizeMapping = sizeMapping; } AdUnits.Add(unit); _adCounter++; return(new HtmlString(placeholder)); }
public AdUnitViewModel Register(AdType type) { // Get position of current requested Ad int position = 1; if (AdsCounterByType.ContainsKey(type)) { position = ++AdsCounterByType[type]; } else { AdsCounterByType.Add(type, position); } // Instanciate AdUnit AdUnitViewModel adUnit = new AdUnitViewModel(type, position); // Add to the list AdUnits.Add(adUnit); return(adUnit); }
/// <summary> /// Defines an ad unit in publisher tags without creating the container on the page. /// </summary> /// <param name="unitName">Name of the ad unit as set in DFP.</param> /// <param name="size">Ad unit size.</param> /// <param name="id">ID of the ad unit container.</param> public static void DefineAdUnit(string unitName, string size, string id) { if (String.IsNullOrWhiteSpace(unitName)) { throw new ArgumentNullException("unitName"); } if (String.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("id"); } var unit = new AdUnit { UnitName = unitName, Size = size, Display = false, Id = id }; AdUnits.Add(unit); }
public override void RegisterAds(AdManagerViewModel adManager) { AdUnits.Add(adManager.Register(AdType)); }