Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7903677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:48:31+00:00 2026-06-03T09:48:31+00:00

I have been reading the web and trying out things for days looking for

  • 0

I have been reading the web and trying out things for days looking for a way to show the Google Adsense ads through jQuery mobile transitions without breaking the ToS. I am a bit stuck so I turn to the wisest community.

The Adsense tag is made of three scripts (i) a general one, (ii) a list of slots and (iii) the display itself. The first two go in the <head>, the latter in the <body>.

I can display the ads on my first page just fine. The problem comes with page transition.

Since jQuery Mobile does not reload the <head>, an option is to prepare the googletag while loading the <head> the first time. This sets the limit to a maximum of three ads per page, which, across a whole site is not a lot. Plus it means that you will have to move ad <div> around, which is not so great either. Finally, it means that you may load ads and not display them until the user goes to the page where it belongs, if ever. Which is not so ToS compatible either.

Is there a way to load a fresh new ad on each transition? If yes, where do I put the Google scripts to make sure they load properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:48:33+00:00Added an answer on June 3, 2026 at 9:48 am

    I found a way to get it to work in Google DFP with Adsense plugged into DFP. DFP is more flexible so it was easier.

    Here is what I used:

    • In the <head>: I put the google scripts and defined all the adslots for the whole website (you will get it with the “generate tags”).
    • On each page: you put the <body> part of the script like you would do anywhere else.

    With this, you will be able to get a new ad served each time you load a new page. However, if you browse between pages, you will never get them to refresh.

    To make for this, you can use googletag.pubads().refresh(). However, you want to only refresh the slots that are in the page that you are loading, otherwise you break some terms and conditions. Plus, you cannot refresh slots that have not been displayed yet, so it will fail if you defined slots for the whole website but all the pages have not been loaded yet, which is quite likely.

    But you can pass the slots that are in the current page to the refresh() function. Here is how I did it:

    function refreshAds() {
      // Get all the slots
      var allSlots = googletag.pubads().getSlots();
      var slotsToRefresh = Array();
      // Select the slots that are on the current page based on their dom Id
      for (var i=0; i<allslots.length; ++i)
        if (isSlotIdOnTheCurrentPage(allSlots[i].getSlotId().getDomId())) 
          slotsToRefresh.push(allSlots[i]); // I let you implement the logic behind naming ids slots and divs
      if (slotsToRefresh.length > 0)
        googletag.pubads().refresh(slotsToRefresh);
    }
    
    $(document).on("pagechange", function() {refreshAds();})
    

    There you go, each time you go back to a page, the slots are refreshed, each time you go to a new page, a new slot is created (provided that it was defined in the <head>).

    I hope it will help! There might be a way to get it to work seamlessly in Adsense but I did not try.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading through Intuit's new IPP Federated App documentation. I am trying
I have been reading all over the web about this and still can't understand
I have been reading the docs and playing with different EventQuery parameters for days
I have been reading through this wonderful website regarding the recommended Python IDEs and
I have been reading through what seems to be a good tutorial on rest
I been having trouble trying to figure this out. When I think I have
I have been reading several jQuery tutorials on the web. They all seem very
I have been reading this link from Steven Sanderson about mobile web development http://www.asp.net/learn/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application
Have been reading about async and tasks and been attempting to convert the CopyFileEx
i have been reading this interesting article which is increasing my every growing confusion

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.