...

View Full Version : insert google ads into javascript..?



tomystein
06-19-2012, 09:54 AM
I have this code which is working fine:


<script>
jQuery(document).ready( function() {
$.getJSON( "http://smart-ip.net/geoip-json?callback=?",
function(data){
console.log(data);
var c = data.countryCode;
if(c=="US" || c=="US" ){
document.getElementById('geo_us').innerHTML = 'US Visitor'; } else {
document.getElementById('geo_us').innerHTML = 'Not US Visitor';}
/*
this service needs ip
var ip = data.host;
alert(ip);
$.getJSON( "http://freegeoip.net/json/"+ip,
function(data){
console.log(data);
}
);*/
}
);

});
</script>

And this div:


<div id="geo_us"></div>
I want the "US Visitor" to be a Google tag but I can't make it work.


<script type='text/javascript'>
googletag.defineSlot('xxxxxxxxxxxx', [160, 600], 'div-gpt-ad-xxxxxxxxxx').addService(googletag.pubads());
googletag.pubads().enableSyncRendering();
googletag.enableServices();
</script>
<div id='div-gpt-ad-xxxxxxxxx' style='width:160px; height:600px;'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-xxxxxxxxxxxx');
</script>
</div>

This Google ad is working if I don't put it inside the script (innerhtml).

What should I do?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum