Osclass Support Forums

Osclass plugin support => Advertisement Manager Plugin => Topic started by: Zbyszek Ochelski on June 13, 2018, 08:49:29 AM

Title: Show banners by country by js code (9 field)
Post by: Zbyszek Ochelski on June 13, 2018, 08:49:29 AM
Hi, is possible to show banners in specifiek countries using js code like:

Code: [Select]
// List of countries we want to show banner
var whitelist = ['US', 'CA', 'UK', 'IN']

// Getting the country code from the user's IP
$.get("https://api.ipdata.co", function (response) {

  // Checking if the user's country code is in the whitelist
  if (blacklist.includes(response.country_code)) {
    ('show banner');
  } else {
  ("Don't show this banner, but show other")
  }
}, "jsonp");

Please show me how i can do that correctly?
Title: Re: Show banners by country by js code (9 field)
Post by: MB Themes on June 13, 2018, 01:31:18 PM
Hello
Theoretically yes, if you complete that code.
Title: Re: Show banners by country by js code (9 field)
Post by: Zbyszek Ochelski on June 13, 2018, 07:11:14 PM
the problem is i can't complete this code because i find it on internet and im not programmer... i dont know how... and i dont know also what code i have to use from Your plugin to written in this code, is dificoult to finish this code? i think solution like this will help many people with problem divide banners on countrys or regions.
Title: Re: Show banners by country by js code (9 field)
Post by: MB Themes on June 13, 2018, 09:02:33 PM
You can put region/country name to keyword to prioritize banner on search page in certain geo.
Code is just "hand-made" and would need updates when there is new banner...
Title: Re: Show banners by country by js code (9 field)
Post by: Zbyszek Ochelski on June 14, 2018, 07:49:23 PM
i can put this code for each banner i think. Ok keywords, but what when user dont browsing by region or country. I dont want to show users banners from deutchald when somebody browsing portal from spain...
Title: Re: Show banners by country by js code (9 field)
Post by: MB Themes on June 14, 2018, 08:48:04 PM
That could be secured from php side, but such geolocation use to be not accurate.