I have this code which is working fine:

Code:
    <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:

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

Code:
    <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?