From 2124073de92b5f0f862dd9e6455ef4204c7a5ebf Mon Sep 17 00:00:00 2001 From: Ladydanger Date: Wed, 19 Aug 2015 10:45:03 +1000 Subject: [PATCH 1/5] Initial planning of custom targeting locations --- .../discourse/components/google-dfp-ad.js.es6 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index d82b820..4ef697d 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -39,7 +39,11 @@ function loadGoogle(settings) { 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)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); - googletag.defineSlot(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').addService(googletag.pubads()); + googletag.defineSlot(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'). + + // Inventory level custom targeting goes here for each of the defined ad units. + setTargeting('location', ['melbourne']). + 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) { const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); @@ -56,6 +60,10 @@ function loadGoogle(settings) { const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes)); googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads()); } + + // Page Level custom targeting goes here. + googletag.pubads().setTargeting('gender', ['male']); + googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); From ce83cb121c98193bebd3372b5606cd2c82e94aff Mon Sep 17 00:00:00 2001 From: vi Date: Thu, 20 Aug 2015 08:23:55 +1000 Subject: [PATCH 2/5] Temporarily removed custom targeting --- .../discourse/components/google-dfp-ad.js.es6 | 20 +++++++++---------- ...3562e98e357709eaba07c3a0e9054afdd7697.css} | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) rename auto_generated/{plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css => plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css} (65%) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index 4ef697d..5a093cc 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -35,15 +35,14 @@ function loadGoogle(settings) { } // Define our ad units - extend for mobile view. + // Inventory or slot level custom targeting goes here for each of the defined ad units - needs input and injection. + // For each ad slot, if there is set target, then don't put semicolon in after addService, if so, then add it in to close off function. + // Need to add something to the actual site itself... on the page googletag.pubads().setTargeting(‘publisher’, ‘affiliate1′);: 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)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); - googletag.defineSlot(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'). - - // Inventory level custom targeting goes here for each of the defined ad units. - setTargeting('location', ['melbourne']). - addService(googletag.pubads()); + googletag.defineSlot(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').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) { const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); @@ -53,17 +52,18 @@ function loadGoogle(settings) { if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) { const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes)); - googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads()); + googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested') + .addService(googletag.pubads()); } if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) { const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes)); const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes)); - googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads()); + googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom') + .addService(googletag.pubads()); } - // Page Level custom targeting goes here. - googletag.pubads().setTargeting('gender', ['male']); - + // Page Level custom targeting goes here - needs an input section and also ad tags on the relevant pages + // googletag.pubads().setTargeting("gender","female"); googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); diff --git a/auto_generated/plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css b/auto_generated/plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css similarity index 65% rename from auto_generated/plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css rename to auto_generated/plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css index 9b1f860..677144a 100644 --- a/auto_generated/plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css +++ b/auto_generated/plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css @@ -1,20 +1,20 @@ -.discourse-google-dfp { +.google-dfp-ad { padding: 3px; margin-bottom: 10px; clear: both; } -.discourse-google-dfp .dfp-ad-unit { +.google-dfp-ad .dfp-ad-unit { margin: 0 auto; } -.discourse-google-dfp .google-dfp-ad-label { +.google-dfp-ad .google-dfp-ad-label { width: 728px; margin: 0 auto; } -.discourse-google-dfp .google-dfp-ad-label h2 { +.google-dfp-ad .google-dfp-ad-label h2 { margin: 4px 0 !important; color: #858a8c; text-transform: uppercase; From f98751323ed8439746cdc3c27013405bfc5c19ae Mon Sep 17 00:00:00 2001 From: vi Date: Thu, 20 Aug 2015 10:19:29 +1000 Subject: [PATCH 3/5] Added publisher id to code --- .../discourse/components/google-dfp-ad.js.es6 | 10 ++++------ config/locales/server.en.yml | 1 + config/settings.yml | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index 5a093cc..f99d36a 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -42,24 +42,22 @@ function loadGoogle(settings) { 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)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); - googletag.defineSlot(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').addService(googletag.pubads()); + 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').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) { const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes)); - googletag.defineSlot(settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads()); + googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads()); } if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) { const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes)); - googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested') - .addService(googletag.pubads()); + googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads()); } if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) { const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes)); const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes)); - googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom') - .addService(googletag.pubads()); + googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads()); } // Page Level custom targeting goes here - needs an input section and also ad tags on the relevant pages diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6df20c8..b4701ec 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,5 +1,6 @@ en: site_settings: + dfp_publisher_id: "Put in your publisher id here" dfp_show_topic_list_top: "Disable topic_list_top ad" dfp_topic_list_top_code: "Show leaderboard ad above topic lists." topic_list_top_ad_sizes: "Choose your ad size" diff --git a/config/settings.yml b/config/settings.yml index f076fb3..93a492a 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -1,4 +1,7 @@ ad_plugin: + dfp_publisher_id: + client: true + default: '' dfp_topic_list_top_code: client: true default: '' From 9e56fae22a1325646dc7d10ae41943399bb9b419 Mon Sep 17 00:00:00 2001 From: vi Date: Thu, 20 Aug 2015 21:14:50 +1000 Subject: [PATCH 4/5] Added gender inventory level slot targeting to be tested --- assets/javascripts/discourse/components/google-dfp-ad.js.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index f99d36a..6784355 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -42,7 +42,7 @@ function loadGoogle(settings) { 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)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); - 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').addService(googletag.pubads()); + 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').setTargeting('gender', ['female']).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) { const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); From 86054c51640e54a4e2d8cf7c95aa2520e904ee7f Mon Sep 17 00:00:00 2001 From: vi Date: Fri, 21 Aug 2015 11:19:18 +1000 Subject: [PATCH 5/5] Added input slots for custom targeting in dfp --- .../discourse/components/google-dfp-ad.js.es6 | 14 ++++++++------ config/locales/server.en.yml | 4 ++++ config/settings.yml | 14 +++++++++++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index 6784355..99f2d90 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -16,7 +16,7 @@ function splitHeightInt(value) { var str = value.substring(4, 7); return str.trim(); } - + function loadGoogle(settings) { if (_loaded) { return Ember.RSVP.resolve(); @@ -35,14 +35,16 @@ function loadGoogle(settings) { } // Define our ad units - extend for mobile view. - // Inventory or slot level custom targeting goes here for each of the defined ad units - needs input and injection. - // For each ad slot, if there is set target, then don't put semicolon in after addService, if so, then add it in to close off function. - // Need to add something to the actual site itself... on the page googletag.pubads().setTargeting(‘publisher’, ‘affiliate1′);: + // if statement? the code should be able to run without the custom targeting settings 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)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); - 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').setTargeting('gender', ['female']).addService(googletag.pubads()); + 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') + // Inventory or slot level custom targeting goes here for each of the defined ad units - needs input and injection. + // The ad runs with .setTargeting('gender', ['female']) + .settings.dfp_topic_list_top_custom_targeting_code + .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) { const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); @@ -61,7 +63,6 @@ function loadGoogle(settings) { } // Page Level custom targeting goes here - needs an input section and also ad tags on the relevant pages - // googletag.pubads().setTargeting("gender","female"); googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); @@ -84,6 +85,7 @@ export default Ember.Component.extend({ return "div-gpt-ad-" + this.get('placement'); }.property('placement'), +//settings.dfp_topic_list_top_custom_targeting_code _initGoogleDFP: function() { var self = this; loadGoogle(this.siteSettings).then(function() { diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index b4701ec..2a609f3 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -4,13 +4,17 @@ en: dfp_show_topic_list_top: "Disable topic_list_top ad" dfp_topic_list_top_code: "Show leaderboard ad above topic lists." topic_list_top_ad_sizes: "Choose your ad size" + dfp_topic_list_top_custom_targeting_code: "Add your custom targeting code - see instructions" dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad" dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream" topic_above_post_stream_ad_sizes: "Choose your ad size" + dfp_topic_above_post_stream_custom_targeting_code: "Add your custom targeting code - see instructions" dfp_show_topic_above_suggested: "Disable topic_above_suggested ad" dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics" topic_above_suggested_ad_sizes: "Choose your ad size" + dfp_topic_above_suggested_custom_targeting_code: "Add your custom targeting code - see instructions" dfp_show_post_bottom: "Disable post_bottom ad" dfp_post_bottom_code: "Show leaderboard ad post_bottom topics" dfp_nth_post_code: "Choose the Nth position for your ad to show" post_bottom_ad_sizes: "Choose your ad size" + dfp_post_bottom_custom_targeting_code: "Add your custom targeting code - see instructions" \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index 93a492a..728065b 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -23,6 +23,9 @@ ad_plugin: dfp_show_topic_list_top: client: true default: false + dfp_topic_list_top_custom_targeting_code: + client: true + default: '' dfp_topic_above_post_stream_code: client: true default: '' @@ -44,6 +47,9 @@ ad_plugin: dfp_show_topic_above_post_stream: client: true default: false + dfp_topic_above_post_stream_custom_targeting_code: + client: true + default: '' dfp_topic_above_suggested_code: client: true default: '' @@ -65,6 +71,9 @@ ad_plugin: dfp_show_topic_above_suggested: client: true default: false + dfp_topic_above_suggested_custom_targeting_code: + client: true + default: '' dfp_post_bottom_code: client: true default: '' @@ -88,4 +97,7 @@ ad_plugin: - 250*250 - square dfp_show_post_bottom: client: true - default: false \ No newline at end of file + default: false + dfp_post_bottom_custom_targeting_code: + client: true + default: '' \ No newline at end of file