Showing ad by Discourse Advertising Plugin


(megas) #1

I’m trying to understand how Discourse Advertising Plugin works. My case is DoubleClick for Publishers (DFP).
In repo the divId is not actual id generated by Google Publisher Tag, it’s composed string from “div-gpt-ad-”, placement and optional postNumber, very similar to actual Google Ad Id but it’s an id from Google Generate Tags (for example ‘div-gpt-ad-1472113540637-0’).
In AdPlugin/DFP tab, there’s dfp publisher id but there’s no id of Google Ad.
How the actual Google Ad Id (let’s say ‘div-gpt-ad-1472113540637-0’) is showing ad on site by Discourse Advertising Plugin?


(Jeff Atwood) #2

Any ideas here @neil? Can we improve documentation to address this?


(Neil Lalonde) #3

The Discourse Ad Plugin uses the DFP googletag API, which is how apps can control where to show ads and when to refresh them. By default, you can let DFP’s javascript control everything, including the id of the divs, but you can take control of everything in your own javascript. Discourse needs to control everything otherwise the ads would only fetch once and never change.

To use a div to show an ad:

googletag.display(divId);

To ask DFP to refresh the ad unit and load a new ad according to your ad network rules:

googletag.pubads().refresh([slot.ad]);

(megas) #4

Here’s a snippet generated by Google Publisher Tag in DFP

<div id='div-gpt-ad-1472287147323-0'>
<script>
  googletag.cmd.push(function() { 
    googletag.display('div-gpt-ad-1472287147323-0'); 
  });
</script>
</div>

As far as I understand GoogleTag API uses id 1472287147323-0 to get ad from DFP and display on discourse.
But in the Discourse Ad Plugin documentation there’s no mention of entering this id to DFP form.
It looks like the screenshot relating to DFP is not valid.
I assume that dfp topic list top code is the ad id I should put in to display the advertising on discourse, in my case that is 1472287147323-0


(Neil Lalonde) #6

No, we use the word “code” in the same way that DFP uses it.

Yes, DFP naming is very misleading and causes confusion.


(Leah Kramer) #7

@sevenmaxis, if you are still having trouble, here’s the solution to what was preventing ads from showing up for me:

(I was also scrutinizing the ad tags since that div id is set differently than how DFP does it by default. Turns out it’s ok the way this plugin sets a different div id.)