Custom targeting working for one key and associated values for that one key per ad slot available - problem in multiple keys
This commit is contained in:
parent
a7258f4848
commit
e255a65e32
|
@ -38,41 +38,9 @@ function keyParse(word) {
|
|||
return key;
|
||||
}
|
||||
|
||||
// This sets the key and value for custom targeting
|
||||
var Foo = function(key, value, googletag) {
|
||||
this.locationKey = key;
|
||||
this.locationValue = value;
|
||||
this.googletag = googletag;
|
||||
}
|
||||
|
||||
// setTargeting is not defined. We want to return as a method - PROBLEM 1
|
||||
Foo.prototype.bar = function() {
|
||||
return this.googletag.setTargeting(this.locationKey, this.locationValue);
|
||||
}
|
||||
|
||||
// This should call googletag.setTargeting(key for that location, value for that location)
|
||||
function custom_targeting(key_array, value_array) {
|
||||
for (var i = 0; i < key_array.length; i++) {
|
||||
var wordValue = valueParse(value_array[i]);
|
||||
var f = new Foo(key_array[i], wordValue, googletag);
|
||||
f.bar();
|
||||
console.log("works!");
|
||||
}
|
||||
}
|
||||
|
||||
// END of Coaches Note
|
||||
|
||||
// splitting values
|
||||
/*var custom_values = [];
|
||||
var word = keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code);
|
||||
var wordValue;
|
||||
for (var i = 0; i < word.length; i++) {
|
||||
wordValue = valueParse(word[i]);
|
||||
custom_values.push(wordValue);
|
||||
}*/
|
||||
|
||||
|
||||
//PageTracker.current().on('change', function(url) {
|
||||
|
||||
function loadGoogle(settings) {
|
||||
if (_loaded) {
|
||||
return Ember.RSVP.resolve();
|
||||
|
@ -90,6 +58,37 @@ function loadGoogle(settings) {
|
|||
console.log('googletag is undefined!');
|
||||
}
|
||||
|
||||
var topic_list_top = googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(Discourse.SiteSettings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(Discourse.SiteSettings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top');
|
||||
|
||||
var DefineSlotFactory = {
|
||||
create: function(type){
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
// This sets the key and value for custom targeting
|
||||
var Foo = function(key, value, googletag) {
|
||||
this.locationKey = key;
|
||||
this.locationValue = value;
|
||||
this.googletag = googletag;
|
||||
}
|
||||
|
||||
// setTargeting is not defined. We want to return as a method - PROBLEM 1
|
||||
Foo.prototype.bar = function() {
|
||||
return this.googletag.setTargeting(this.locationKey, this.locationValue);
|
||||
}
|
||||
|
||||
// This should call googletag.setTargeting(key for that location, value for that location)
|
||||
function custom_targeting(key_array, value_array) {
|
||||
for (var i = 0; i < key_array.length; i++) {
|
||||
var wordValue = valueParse(value_array[i]);
|
||||
var f = new Foo(key_array[i], wordValue, DefineSlotFactory.create(topic_list_top));
|
||||
return f.bar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
googletag.cmd.push(function() {
|
||||
if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) {
|
||||
const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes));
|
||||
|
@ -98,9 +97,8 @@ function loadGoogle(settings) {
|
|||
googletag.defineSlot(settings.dfp_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads());
|
||||
}
|
||||
else {
|
||||
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top')
|
||||
custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code)))
|
||||
googletag.addService(googletag.pubads());
|
||||
.addService(googletag.pubads());
|
||||
}
|
||||
}
|
||||
if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) {
|
||||
|
|
Loading…
Reference in New Issue