Jump to content

Geotargeting and Presta


irabbit

Recommended Posts

Hello, friends.

Can anyone explain me how i can add phone number to header and that automatically changes based on visitor geolocation.

 

Im used this code in contentBox module:

<script>// <![CDATA[
window.onload = $.getJSON("http://ip-api.com/json/?callback=?", function(data) {
    if(data.regionName == 'Moscow'){
       jQuery(".region-phone").text('+7 (333) 333-33-33');
       jQuery(".region-phone-href").attr('href', 'tel:+73333333333');
     } else if(data.regionName == 'St.-Petersburg'){
       jQuery(".region-phone").text('+7 (222) 222-22-22');
       jQuery(".region-phone-href").attr('href', 'tel:+72222222222');
     } else if(data.regionName == 'Chelyabinsk'){
       jQuery(".region-phone").text('+7 (111) 111-11-11');
       jQuery(".region-phone-href").attr('href', 'tel:+71111111111');
     }  else {
       jQuery(".region-phone").text('+7 (000) 00-00-00');
       jQuery(".region-phone-href").attr('href', 'tel:+70000000000');
   }
});
// ]]></script>
<div class="region-phone"></div>

But it didn't work after i turned on ssl.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...