Show Double Click for Publishers (DFP) ads over https for single page web apps

Usage no npm install needed!

<script type="module">
  import viceview from '';



I created this module for displaying Adsense ads over https on my single page web app:

You will find that AdSense codes will not work over https and do not support dynamic loading. For example when a user changes a page in your Single Page Web App (SPA).


To use ViceView you will need a working AdSense account and be signed up for Double Click for Publishers.

Log into DFP and create some adunits:

DFP Screenshot

Get the tracking code:

Step 1 DFP Screenshot2

Step 2 DFP Screenshot

Now in your SPA you can write:

  ViceView.showAdsense({adslot: {slot: "myslot", sizes: "[300,100]", id:"your adsenseid"}, element: "element", adwidth: 300, adheight: 100});

And the ad will be displayed with the specified size within the element you specified.


In the ViceView module go into the example directory and edit server.js.
Update the adslots variable with your adcodes.

Now run:

    cd example
    npm install
    node server

Open your web browser and go to http://localhost:9009 in your web browser.

Here is an youtube video showing the example app running:

Adsense for SPA