Post by jasonc310771 » Wed Apr 08, 2015 10:54 pm

I have added google adsense fine using the following method...

Adding the following in to the footer module.

Code: Select all

<object src="googlead.php"></object>
and having the file googlead.php in the root folder of the cart.

But I am unable to execute PHP in this file, not sure why, so opted to using javascript to display random ad images of my own.

googlead.php

Code: Select all

<script>
function showad() {
thisSiteIs = 'abcd';
r = (int) rand(1, 1);
document.write(r);
		if (r == 1) {
		document.write('<a href="http://www.site.com/?ref=' + thisSiteIs + '" title="**" target="_blank"><img src="http://www.site.com/myAds/my-ad-001.jpg" alt="**" style="border:0;"></a>');
		} else if (r == 2) {
		document.write('<a href="http://www.site.com/?ref=' + thisSiteIs + '" title="**" target="_blank"><img src="http://www.site.com/myAds/my-ad-002.jpg" alt="**" style="border:0;"></a>');
		} else if (r == 3) {
		document.write('<a href="http://www.site.com/?ref=' + thisSiteIs + '" title="**" target="_blank"><img src="http://www.site.com/myAds/my-ad-003.jpg" alt="**" style="border:0;"></a>');
		} else if (r == 4) {
		document.write('<a href="http://www.site.com/?ref=' + thisSiteIs + '" title="**" target="_blank"><img src="http://www.site.com/myAds/my-ad-004.jpg" alt="**" style="border:0;"></a>');
		} else if (r == 5) {
		document.write('<a href="http://www.site.com/?ref=' + thisSiteIs + '" title="**" target="_blank"><img src="http://www.site.com/myAds/my-ad-005.jpg" alt="**" style="border:0;"></a>');
		} else {
				document.write('<'+'script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"><'+'/script>');
				document.write('<' + 'ins class="adsbygoogle"');
				document.write('     style="display:block"');
				document.write('     data-ad-client="ca-pub-00000000000000000"');
				document.write('     data-ad-slot="000000000000000"');
				document.write('     data-ad-format="auto"></ins>');
				document.write('<'+'script>');
				document.write('(adsbygoogle = window.adsbygoogle || []).push({});');
				document.write('<'+'/script>');
		}
}
showadd();
</script>
but nothing shows in the space anymore.

-------------------------------------------
EDITED:
having the following works, but wanted to be able to choose which image shows.

Code: Select all

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-00000000000000000"
     data-ad-slot="0000000000000000"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
-------------------------------------------

how could I do this so I can choose which ad shows ?

Active Member

Posts

Joined
Fri Mar 01, 2013 6:46 pm
Who is online

Users browsing this forum: No registered users and 2 guests