Google Enabler JS


/ Published in: JavaScript
Save to your folder(s)

JavaScript Google Enabler. This code should be placed in all html creatives for Google DoubleClick Studio.


Copy this code and paste it in your HTML
  1. /*Paste this part of the code inside the <head> tag of your html:
  2. <script src="https://s0.2mdn.net/ads/studio/Enabler.js"></script>
  3. */
  4.  
  5. // Google Enabler initializer.
  6.  
  7. function bgExitHandler(e) {
  8. Enabler.exit('Background Exit');
  9. console.log('Exit');
  10. }
  11.  
  12. function pageLoadedHandler() {
  13. if (Enabler.isVisible()) {
  14. adVisibilityHandler();
  15. } else {
  16. Enabler.addEventListener(studio.events.StudioEvent.VISIBLE,
  17. adVisibilityHandler);
  18. }
  19. }
  20.  
  21. function adVisibilityHandler() {
  22. // Here you invoke function to start your banner.
  23.  
  24. }
  25.  
  26. function enablerInitHandler() {
  27. if (Enabler.isPageLoaded()) {
  28. pageLoadedHandler();
  29. } else {
  30. Enabler.addEventListener(studio.events.StudioEvent.PAGE_LOADED, pageLoadedHandler);
  31. }
  32. }
  33.  
  34. function init() {
  35. if (Enabler.isInitialized()) {
  36. enablerInitHandler();
  37. } else {
  38. Enabler.addEventListener(studio.events.StudioEvent.INIT, enablerInitHandler);
  39. }
  40. }
  41.  
  42.  
  43. window.onload = init;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.