1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

Geo Targeting Script

Discussion in 'Pemrograman Web' started by daniar, Aug 1, 2009.

  1. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    Contribute to develop_5889
    http://www.adsense-id.com/forums/showpost.php?p=205816&postcount=20

    Description: Memblokir ads tampil di negara tertentu
    Plugin: IP to Nation + adsense easy insertion
    Platform: WordPress
    Database: http://www.ip2nation.com/ip2nation/Download

    Prosedur:
    Install plugin IP to Nation. Upload SQL database. Tambahkan kode berikut pada Theme.

    PHP:
    <?php //bagian option tampilin ad 
                        
    $adtopfalse
                        
    $countryCode wp_ozh_getCountryCode(); 
                        
    $nonPremiumCountry "cn,in,br,vn,th,ph,id,ir"
                        
    $checkPrem stristr($nonPremiumCountry$countryCode); 
                        if(empty(
    $checkPrem)) { 
                                
    $adtoptrue
                        } 
                        if(
    $adtop) : 
                    
    ?> 
                    <div class="adsensetop"><?php echo show_ad_camp_3(); ?></div> 
                    <?php endif; ?>
    Contribute to me, halah2...:D
    Description: Menampilkan ads tertentu pada negara tertentu
    Plugin, database dan prosedur sama seperti yang diatas, kecuali tanpa plugin adsense easy insertion. Kode yang ditambahkan pada Theme:

    PHP:
    <?php 
    $cc 
    wp_ozh_getCountryCode();
    if(
    $cc == "us") {
    // It’s a US visitor. Display the US ad here.
    echo "US ad code goes here.";
    // end if us

    elseif($cc == "uk") {
    // It’s a UK visitor. Display the UK ad here.
    echo "UK ad code goes here.";
    // end if uk

    else {
    // It’s an international visitor (not from one of the above countries). Display the international ad here.
    echo "International ad code goes here.";
    // end else.                ?>
    <?php ?>
    Script adsense untuk script kedua:
    Code:
    <script type=\"text/javascript\"><!--
    google_ad_client = \"pub-xxxxxxxxxxxxxxx\";
    google_ad_slot = \"xxxxxxxxx\";
    google_ad_width = 728;
    google_ad_height = 15;
    //-->
    </script>
    <script type=\"text/javascript\"
    src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
    </script>
    Reference:
    HTML:
    http://www.websitepublisher.net/article/geotargetting-php/
     
    Last edited: Aug 1, 2009
    phims, rocky, silentlight and 3 others like this.
  2. silentlight

    silentlight Super Hero

    Joined:
    Aug 12, 2008
    Messages:
    1,094
    Likes Received:
    32
    Location:
    Jogja
    itu code adsense diubah gpp ??? ada cara yg ga ngubah code adsense ga??:hmm:
     
  3. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    Itu bukan diubah, tapi supaya bisa dibaca ama script phpnya. Ada yang punya script geo targeting untuk blogspot? Ini ada referensi tapi wkatu dicoba tidak berhasil.

    Code:
    <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
    <script language="JavaScript">
    var cc = geoip_country_code();
    if (cc == "US" || cc == "CA"){ // change the country code as per your req.
    Your Ad here Country specific (USA or Canada)
    }else{
    Your Ad here Country specific (NON USA or Canada)
    }
    </script>
    Mungkin ada yang bisa betulkan scriptnya
    Reference:
    HTML:
    http://www.niharsworld.com/2008/02/18/geo-target-ads-based-on-visitors-location/
     
  4. stardawn

    stardawn Newbie

    Joined:
    Aug 3, 2009
    Messages:
    26
    Likes Received:
    2
    Location:
    internet
  5. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    Ini maksudnya apa? databasenya ta? bisa dishare penggunaan scriptnya? aku baca kok ga mudeng, maklum, bukan programmer :D
     
  6. stardawn

    stardawn Newbie

    Joined:
    Aug 3, 2009
    Messages:
    26
    Likes Received:
    2
    Location:
    internet
    ya,mengambil informasi dari database hostip.info ,coba digabungkan dengan ajax lebih cepat ...

    contoh :
    PHP:
    <?php

    function get_content($url)
    {
        
    $ch curl_init();

        
    curl_setopt ($chCURLOPT_URL$url);
        
    curl_setopt ($chCURLOPT_HEADER0);

        
    ob_start();

        
    curl_exec ($ch);
        
    curl_close ($ch);
        
    $string ob_get_contents();

        
    ob_end_clean();
       
        return 
    $string;    
    }

    #usage:
    $content get_content ("http://api.hostip.info/country.php");
    echo 
    $content;
    ?>

     
    glodakan and develop_5889 like this.
  7. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    ga ngerti blas....:lol:
    script adsnya ditaruh dimana??? terus pilih countrynya piye?:pusing:
     
  8. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    Alternatif PHP script geo targeting menggunakan http://www.hostip.info/ seperti yang disebutkan oleh stardawn

    PHP:
    <?php
    $ip 
    $_SERVER['REMOTE_ADDR'];
    $country file_get_contents('http://api.hostip.info/country.php?ip='.$ip);
    if (
    $country=="US") {
    echo 
    "<American-English Ringtone Ad Tag>"; }
    elseif (
    $country=="AU" OR $country=="UK" OR $country=="IE") {
    echo 
    "<British-English Ringtone Ad Tag>"; }
    else {
    echo 
    "<YPN Ad Tag>"; }
    ?>
    Contribute to Keith Mander - nih orang pernah kerja di Google, sekarang kerja di facebook, keyen...

    Test update: berhasil setelah tanda petiknya diganti, script ini tidak perlu database di MYSQL jadi lebih oke! Jangan lupa script adsnya diganti seperti yang tertulis diatas.
     
    Last edited: Aug 10, 2009
    develop_5889 and mawarkuning like this.
  9. mawarkuning

    mawarkuning Super Hero

    Joined:
    Aug 29, 2007
    Messages:
    1,503
    Likes Received:
    110
    Bolehkah adsense pake trick semacam ini [sebagai alternatif ads berdasarkan IP] ?
     
  10. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    ya pasti boleh dunk..ini benernya lebih kepada ads yang visitornya ditarget harus negara tertentu
     
  11. develop_5889

    develop_5889 Ads.id Starter

    Joined:
    May 22, 2009
    Messages:
    80
    Likes Received:
    8
    Location:
    Surabaya
    Hmm.. ane coba pake hostip itu, IP ane gak kedetek di lokasi manapun :p tp enaknya kl pake script itu, gk perlu berat2 upload database ke server, tinggal ambil dari hostip..
     
  12. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    Masak sih? Aku udah coba pake IP Indonesia ama USA bisa tuh. Kalo pake IP 2 Nation itu perlu rajin diupdate soalnya, kalo ini langsung ambil data lewat APInya.
     
  13. axa

    axa Hero

    Joined:
    Jul 28, 2007
    Messages:
    705
    Likes Received:
    24
    emg make koneksi apa bro? apa make proxy luar negri?
     
  14. develop_5889

    develop_5889 Ads.id Starter

    Joined:
    May 22, 2009
    Messages:
    80
    Likes Received:
    8
    Location:
    Surabaya
    dipikir2... kl pake ini jauh lebih efisien :senyum: terutama untuk yg punya banyak situs.. kl pake yg method ip to nation.... bakal boros space.. :p
     
  15. yujinha

    yujinha Super Hero

    Joined:
    Jun 3, 2009
    Messages:
    1,106
    Likes Received:
    18

    maaf bro bagian dari kode diatas yang merupakan kode adsense yang mana ? apa ini ya echo "<YPN Ad Tag>"; } ?
     
  16. youris

    youris Ads.id Starter

    Joined:
    Jan 11, 2010
    Messages:
    95
    Likes Received:
    1
    tanda petik yang salah bagian mana mas daniyar? kasihin script yang dah betul dunk mas :D tempatku lagi kena smartpricing.. cobain script ini.. mohon bantuannya
     
  17. k0z3y

    k0z3y Ads.id Fan

    Joined:
    Feb 17, 2010
    Messages:
    228
    Likes Received:
    37
    Location:
    https://www.ciusan.com/
    Gan, kalo agan mau ngeliat kota dan negara pengunjung web agan, agan bisa menggunakan script ini:

    masih dari host*ip.info

    PHP:
    function get_location($ip) {
            
    $content = @file_get_contents('http://api.hostip.info/?ip='.$ip);
            if (
    $content != FALSE) {
                
    $xml = new SimpleXmlElement($content);
                
    $coordinates $xml->children('gml'TRUE)->featureMember->children(''TRUE)->Hostip->ipLocation->children('gml'TRUE)->pointProperty->Point->coordinates;
                
    $longlat explode(','$coordinates);
                
    $location['citystate'] = $xml->children('gml'TRUE)->featureMember->children(''TRUE)->Hostip->children('gml'TRUE)->name;
                
    $location['country'] = $xml->children('gml'TRUE)->featureMember->children(''TRUE)->Hostip->countryName;
                
    $location['countrycode'] = $xml->children('gml'TRUE)->featureMember->children(''TRUE)->Hostip->countryAbbrev;
                    return 
    $location;
                }
                else return 
    false;
            }
    cara menggunakan:

    PHP:
    $ip '223.255.231.9';
    $location_info get_location($ip);
    echo 
    $location_info['citystate']; // untuk menampilkan kota
    echo $location_info['country']; // untuk menampilkan negara
    echo $location_info['countrycode']; // untuk menampilkan kode negara
     
  18. mp3online

    mp3online Super Hero

    Joined:
    Jul 19, 2011
    Messages:
    2,228
    Likes Received:
    294
    Location:
    jakarta
    hostip.info databasenya gak lengkap, coba cek ip indosat ini 120.166.26.206 paka hostip, pasti dia gak kenal hehe
    kalau yang ini lebih lengkap
    Code:
    http://www.ip2location.com/demo.aspx
    databasenya hampir selengkap punya maxmind.com
     
  19. daniar

    daniar Super Hero

    Joined:
    Jun 10, 2007
    Messages:
    817
    Likes Received:
    35
    Ya, host-info datanya memang ga lengkap. Yang
    Code:
    http://www.ip2location.com/demo.aspx 
    bayar ya?
     
  20. mp3online

    mp3online Super Hero

    Joined:
    Jul 19, 2011
    Messages:
    2,228
    Likes Received:
    294
    Location:
    jakarta
    ada yang gratis ada yang bayar, versi gratisnya database gak lengkap.
    database yang full mungkin bisa dicari gratis di filesharing :)

    ---------- Post added at 01:13 PM ---------- Previous post was at 12:40 PM ----------

    kalau aku untuk geoIP ngegrab situs orang :)
    contoh punyaku:
    Code:
    http://ogah.uv.ro/geoip.php
    bisa juga cek IP lain http://ogah.uv.ro/geoip.php?ip= tulis IPnya
    
    dulu aku pernah juga hasil grab terus aku bikin API, tapi hostingnya sekarang gulung tikar, mau bikin lagi males :)
     

Share This Page