Traffic Routing 1: Route by country based on IP address lookup

Prerequisites: Getting Started: Rules And Rulesets


One basic kind of rule you can set up in Addue concerns figuring out what country your link visitors are coming from when they click on your links and routing the traffic accordingly to a landing page of your choosing. For example you might have different websites you'd want to show visitors coming from the USA vs visitors coming from the UK. One well-established way of doing this is based on figuring out the country from the IP address of the visitors. Every browser on the internet is assigned such an address and it is usually quite an accurate way to determine countries. 

(You don't actually have to know more about IP addresses than the above to follow this tutorial and use Addue, but if you like you can learn more here: https://en.wikipedia.org/wiki/IP_address)

Let's assume you have a website at http://jollyniceflowers.com as in the previous tutorial. Once again we'll assume 2 landing pages on this site: http://jollyniceflowers.com/page1 and http://jollyniceflowers.com/page2. We're going to set up the required Addue rules to do the following:

1. Send all US traffic to http://jollyniceflowers.com/page1
2. Send all UK traffic to http://jollyniceflowers.com/page2
3. Send all other traffic to http://jollyniceflowers.com 

Setting all this up will require a ruleset composed of 3 rules. To enter the first one in, go to your Addue account, click on "Insert New Rule", and choose "CR - Country Routing Rule" as the dropdown menu option. The rule entry form for country routing comes up:



Fill out the form as in the image above. Use "tutorial2" as the ruleset ID, http://jollyniceflowers.com/page1 as the destination URL and US as the country code.

A note on country codes: Addue uses the industry standard ISO-3166 codes. These are 2 letter codes which uniquely identify countries and are easy to guess in many cases. For example US is the code for the USA and UK for the United Kingdom, as you might expect. We advise you use the link provided in the form to look up the code for each country to make sure you have the right one if you're not familiar with the codes though. (By the way, these codes are not related to the 2 letter codes Addue uses to identify rules on its system, such as CR for country routing).

Hit Submit on the form to enter the rule. Now enter 2 more rules. The second rule, as you probably guessed is similar to the one you just entered. It's another CR-type country routing rule, with "tutorial2" as the ruleset ID, http://jollyniceflowers.com/page2 as the destination URL and UK as the country code.

Finally you'll need a 3rd rule to route all other traffic to http://jollyniceflowers.com as desired. In Addue, we call this a "Default Rule". Default rules are used in combination with certain rules like the CR country routing ones to tell Addue what to do with the traffic if no other rules apply. For country routing, you should always have a default rule present besides the CR ones.

To enter this rule, go to "Insert New Rule" and this time choose the "DR - Default Rule" option:



Enter the rule as shown. The ruleset ID needs to be the same as the previous two country routing rules you entered ("tutorial2") to associate it with them. The destination URL is the http://jollyniceflowers.com URL desired. Click Submit to enter the rule and you're done. All traffic which Addue can't identify as originating from the US or UK will now be sent to http://jollyniceflowers.com.

You can see the three rules you've entered under the List/Edit/Delete Rules section. Focusing on the tutorial2 ruleset (click tutorial2 in any of those 3 rules in the rules listing) should bring up a page similar to the one below:


At the top of the list you'll see the Addue link you'll use to invoke this ruleset: 

http://addue.com/r/route/246/tutorial2

All traffic sent to this link will be redirected to http://jollyniceflowers.com/page1 if coming from the USA, http://jollyniceflowers.com/page2 if from the UK, and http://jollyniceflowers.com/ otherwise. A record of all clicks, indicating the destination URL Addue decided to send them to, can be seen in your Click History as usual.

(As noted in the introductory tutorial about rules and rulesets, the 246 number in the link will be different in your case. That's your unique account ID number on Addue, and all your Addue links will have your unique number in them). 

And that wraps it up for this tutorial. If you have any questions about country level routing this tutorial didn't cover, please feel free to drop us a line!


Share This Article: