Skip navigation
SmilingGoat
Currently Being Moderated

How do I select an ad rotator based on users location

Jul 29, 2012 12:37 AM

Tags: #jquery #json #ajax

I have the following requirement and am not sure how one can go about achieving this as no back-end scripting is allowed in BC

 

On every page a set of ad rotators are displayed based on the users location - this could be a casual user wandering onto the web site or a registered member.

 

There are over 400 advertising regions (lets just call them cities).  When a user wanders onto the web site, we know the IP address and can then determine the city with external services.

 

Now that we know the City the person is from, we want to present the page with the correct Banner-ad.

 

It is obviosly not a good idea to load 400 banner adverts and unhide the one required.

 

Can anyone help me with this problem?

 

I am no expert on JQuery/JSON/AJAX etc, so some examples would be appreciated.

 

Thanks in advance

 
Replies
  • Currently Being Moderated
    Jul 31, 2012 7:24 AM   in reply to SmilingGoat

    You can go this way:

     

    -create a folder where you create pages for every banner, something like /banner/london.html, /banner/newyork.html and so on

    -place one adrotator on each page

    -on the template where you need to have the banner rendered insert the script you use to determine the true location of the user and translate that into the city name

    -create a .js that takes the city name and jQuery.load() the corresponding page from the banner folder, here are a few examples of the load method - http://www.w3schools.com/jquery/ajax_load.asp

     

    Hope this helps!

     

    PS - you can even have a single page for all adrotator, each wrapped in a div with a unique "city" ID and load the div containing the needed adrotator, something like:

     

    <html>

    <head>

    </head>

    <body>

    <div id="newyork">

    {module_adrotator,15264}

    </div>

    <div id="london">

    {module_adrotator,15265}

    </div>

    </body>

    </html>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points