Banner ads only visible in a certain country?
#1 20-09-2013 
Hello, a company asked me to make banner ads visible only in Italy (I have to get clicks only by Italian IPs). Confused
Never felt this thing...I have set it in the cpanel?

Thank you for the help Smile

0
#2 20-09-2013 
Yea, this can be done, here is a stack overflow answer:

http://stackoverflow.com/questions/10978...ds-banners

1
#3 20-09-2013 
Thank you Lee, so I have to use this script:

PHP Code:
$.get("http://ipinfo.io", function (response) {
    $(
"#ip").html("IP: " response.ip);
    $(
"#address").html("Location: " response.city ", " response.region);
    $(
"#details").html(JSON.stringify(responsenull4));
}, 
"jsonp"

Script gets infos from http://ipinfo.io and I call it in html with id="details".

But how can I add <if> condition? Sad <if IP is from IT country, then> show banner </if>

EDIT: Ok, maybe I have to use this code:
PHP Code:
$.get("http://ipinfo.io", function(response) {
    if(
response.country == "IT") {
        $(
"#ad").html("IT AD HTML");
    }
    else {
        $(
"#ad").html("DEFAULT HTML");
    }
}, 
"jsonp"); 

But I need add page "IT AD HTML.html" and "DEFAULT HTML.html"? Confused I have to add only code of the banner..

Tried with this and nothing:
PHP Code:
<script>
$.
get("http://ipinfo.io", function(response) {
    if(
response.country == "IT") {
        $(
"#ad")("OK");
    }
    else {
        $(
"#ad")("OKOK");
    }
}, 
"jsonp");
</script> 

#ad class there isn't..uhm

EDIT EDIT: maybe I'm near..if I use this and change it in IT I have alert, if I use US I haven't alert:
PHP Code:
<script>
    $(
document).ready(function () {
    $.
get("http://ipinfo.io", function (response) {
        $(
"#address").html(response.region); //http://jsfiddle.net/zK5FN/2/
        
$("input[id=address]").val(response.region);
        var 
testLoc = $('#address').val();
        if(
response.country == "US") {
            
alert("NOES!!!");
        }
    }, 
"jsonp");
});

</script> 

and added jquery code in head Big Grin
(This post was last modified: 20-09-2013 03:12 PM by noiredeb.)

0
#4 20-09-2013 
lol, well, are using it for menu anyway right?

0
#5 20-09-2013 
No no, this is for a banner..arg, how can add this code: <script type="text/javascript" src=""></script> in jquery code?

This works, the last thing is script img of banner:
PHP Code:
<script>
    $(
document).ready(function () {
    $.
get("http://ipinfo.io", function (response) {
        $(
"#address").html(response.region);
        $(
"input[id=address]").val(response.region);
        var 
testLoc = $('#address').val();
        if(
response.country == "IT") {
         (
"<script type="text/javascript" src=""></script>");  //code of the banner
        

    }, 
"jsonp");
});
</script> 

This doesn't work obviuosly Big Grin
(This post was last modified: 20-09-2013 04:48 PM by noiredeb.)

0


Sorry, that is a members only option