Export Script - DoubleClick Studio - Polite Load Code Change

exportscripts

(Darren Hayles) #1

Hi, I have recently been getting ads rejected from some publishers in regard to the polite load of an ad when using the export script for DoubleClick Studio.

I have been able to fix this issue on my local version of the export script, but it would be good for other users to have the downloadable export script updated also.

Here is the official Google page on the issue:
https://support.google.com/richmedia/answer/2672514?hl=en

The fix I have implemented is to the init function as shown below, it changes the text isVisible to isPageLoaded as well as the EventListener:

Existing Export Script (Lines 49 to 56):

	function init() {
		// Polite loading
		if (Enabler.isVisible()) {
			show();
		} else {
			Enabler.addEventListener(studio.events.StudioEvent.VISIBLE, show);
		}
	}

Changes made:

          function init() {
		// Polite loading
		if (Enabler.isPageLoaded()) {
			show();
		} else {
			Enabler.addEventListener(studio.events.StudioEvent.PAGE_LOADED, show);
		}
	}

#2

Thanks for sharing this snippet – do you think that majority of publishers would prefer to wait for PAGE_LOADED to init their ad? Or should we do perhaps both: PAGE_LOADED and isVisible ? I can see arguments both ways, but you (and others viewing this post) would know best.


(Darren Hayles) #3

I would say so, most specs I get through from the publishers usually have a low initial load kb value, and then allow for an additional 2.2mb once the page has loaded

By switching to PAGE_LOADED, this solves the problem by deferring the load of the image and video assets contained within the ad to satisfy the specs.


#4

Can you imagine a situation where the publisher would not want to combine PAGE_LOADED and isVisible and only have PAGE_LOADED? Or are those safe to require at the same time?


(Darren Hayles) #5

Hi Daniel, I’ve been looking into this in a bit more detail. I’ve downloaded a few templates and generated some test ads from GWD (Google Web Designer) and it looks like they never combine the two.

In GWD when publishing an ad, there is an option of a checkbox to specify ‘polite loading’.

50

It might be a good idea to consider adding this option to the ‘Advanced Export’ Box when the DC Studio Export Script has been selected, when checked, the code would then export as Enabler.isPageLoaded PAGE_LOADED, if the box remains unchecked then the generated code would be Enabler.isVisible VISIBLE

I know this is now a much bugger job than just changing the ‘Export script’ and as such is now more of a feature request.

As most publishers still seem to be OK with IsVisible it is probably best to keep the Export Script as is for the time being as the exported file can easily be edited once published.

For any users interested, here is a link to the Studio HTML5 SDK
https://www.google.com/doubleclick/studio/docs/sdk/html5/en/class_studio_Enabler.html

And here is a link to the Doubleclick HTML5 banner build guide
https://support.google.com/richmedia/answer/2672545


(Jonathan Deutsch) #6

Thanks for the extra information - very useful!


(Mark Hunte) #7

I cannot imagine that setting this as an option that shows up in hype as an option for the script should be too hard to do.
It would not be a check box and would need to be a string entry though.

Cannot look at it mysekf at the mo, as I am no were near a Mac for a few says…


(Mark Hunte) #8

Does this work for you.

In the export script I replaced the init code with

function init() {
              ${Polite_Loading}
		}

Then adding the document_arguments

		def document_arguments():
			return ["Polite_Loading"];

and then adding to the global insert_at_head_end

if "Polite_Loading" in export_info["document_arguments"] and export_info["document_arguments"]["Polite_Loading"].lower() == "true":
			is_Polite_Loading =  "/*Polite loading */if (Enabler.isPageLoaded()) {show();} else {Enabler.addEventListener(studio.events.StudioEvent.PAGE_LOADED, show);}"
		else:
			is_Polite_Loading = "if (Enabler.isVisible()) { show(); } else { Enabler.addEventListener(studio.events.StudioEvent.VISIBLE, show);}"

This gives us an option in the Document inspector.

if the option is set to the string “true” then the init() code will be PAGE_LOADED

if the string is anything else or left blank then the init() code will be the VISIBLE code.

I am no expert at py, these export scripts or do adverts (sleeping with the enemy :stuck_out_tongue_winking_eye: ) but this seems to work as far as I can test
Does this work for you?

DoubleClick Studio.hype-export.py.zip (5.7 KB)


(Jonathan Deutsch) #9

Nice! I’d really like to have booleans/checkboxes for the export script arguments :slight_smile:.


(Mark Hunte) #10

Same here👍


(Darren Hayles) #11

Thanks Mark, i’m going to test this update now to see if it all goes well with DoubleClick QA


(Darren Hayles) #12

Everything worked great, Thanks Mark.


(Mark Hunte) #13

Cool.

Glad that worked. Thanks for checking :ok_hand: