One of our clients asked if we could create a Native Ad for DoubleClick for Publishers template for them.
Now DFP (Double Click for Publishers) was working on a solution but the ETA was unknown. To give you and idea what it is, you can take a look at the DFP article.
We looked at our clients requirements and I started working on the creative. I had to create something that I could manipulate the dom once the ad tag has rendered on the page. I also had to make sure that this creative can be seen under user defined templates in the creative library and that the client will be able to make custom edits to each new ad.
I first had to detect a few things, the width of the parent node in which this native ad will be rendering and while doing this I also needed to find the parent node class name so that I could apply additional styling to it, for example width and height which is being set in DFP. I pass all the DFP related values via DFP macros into my code.
You will also notice in my code that I am setting the height of the banner ad as the content resizes smaller, making sure that the content will still fit.
If you are not sure how DFP works and DFP tagging, please let me know, I will assist you with the setup.
You can download my code on github.