How can I use Google adsense ads in a single page application?

The ad code is inserted and works fine on the home page. But as soon as the hash changes,user goes to the second page (Without reload). The ads stop showing. What could be the way around it. I think its loaded once the DOM is loaded and hash change without reload might be causing the issue.

19 thoughts on “How can I use Google adsense ads in a single page application?”

  1. Actually the issue was that in my application I was setting all iframes to Null initially. What i didn’t know that Google ad script were also injecting iframes in the html which too was nulled everytime my fuction was called.
    I corrected that and everything works perfectly. There isn’t any effect of URLhash change on the ads in SPAs.Once DOM loaded, Ads load and stay there.

    Reply

Leave a Comment