Can I use the same position multiple times to display ads in one page? #37
-
If you need to reuse the same script position in a single page to display ads, be sure to change the id of the ad in the script, because you can’t have the same So, when you copy this code remember that in the second, third (etc.) pasted script you have to modify the id name. The
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
What I've found is that this solution only partially works, what has happened with my installation is that when I use this code with the ID changed, I end up with all the same ad on the page. Based on the explanation of how the code works, with the system grabbing ads sequentially from the database, if there are three ads on a page, they all will send a request for the next ad at the same time and will receive the same ad because the pointer to the next ad will not have changed. I've found that the solution that works for me is to put a delay on each instance of the code (after the first one, that doesn't need a delay). I've had to experiment with the length of the delay for each ad to find the right amount of time to have each delay be able to call the database after the previous ad, yet not delay the loading of the ad too long. I'm still working on it but it seems that 350 milliseconds has been relatively consistent for me. I still change the ID, so if I have three ads on a page for my track and field website I use TRACK01, TRACK02, and TRACK03. How I add the delay to the code looks like this:
Since I can't figure out how to format text inside the code block here, I'll have to explain it... Right after /* 300x250 */ and before var k=decode... I've added - Right before the </script> close I've added The delay length is the number at the end (700 in this case), those are milliseconds. The first ad on the page doesn't need the delay, the second is delayed 350 milliseconds, and the third 700. I've run a lot of tests on an individual page with various values and am still tweaking it, but this has seemed to work. Since the additional ads are farther down the page, I've yet to see a noticeable delay in the ad display, but I'm sure there's some page load hit. When I started this I found on a page full of ads 50 milliseconds worked well, but when I put it on my actual page, I was still seeing duplicate ads, so I had to keep bumping the delay. I still see some duplicates, but it's a lot better now and I don't want to increase the delay much more. I'm running my pages in WordPress by taking this code into another plug-in that gives me additional flexibility like having a group of ads rotate in an ad space, which causes another challenge for the code (I was getting the same ad five times in a space until I added the delays). The ultimate solution would be to have the option to select the ads randomly from the database instead of sequentially... The next challenge is to figure out how to get this code to work on an AMP page, Google flags it as custom javascript and doesn't index the page... To see the ads in action, here are a couple of my sites (I'm running 18 sites): https://vcpathletics.com/ LaMonte M. Forthun |
Beta Was this translation helpful? Give feedback.
What I've found is that this solution only partially works, what has happened with my installation is that when I use this code with the ID changed, I end up with all the same ad on the page. Based on the explanation of how the code works, with the system grabbing ads sequentially from the database, if there are three ads on a page, they all will send a request for the next ad at the same time and will receive the same ad because the pointer to the next ad will not have changed.
I've found that the solution that works for me is to put a delay on each instance of the code (after the first one, that doesn't need a delay). I've had to experiment with the length of the delay for each ad to fi…