A great way to save time building call campaigns is to track multiple countries on a single asset. In this guide, we’ll show you how.
Tracking multiple countries on a single landing page is a great to re-use campaign assets and save time when running your call campaigns.
If you do not have a basic understanding of HTML and PHP, this beginner’s guide is a great place to learn how easy it is to work with these tools. The best marketers have a solid foundation in web-based programming languages.
Note: Ringba doesn’t currently support number pools with numbers from different countries, so the first thing you will have to do is create multiple number pools and campaigns in our platform.
For this example we’ll assume you’re running an English campaign in 4 countries, have already generated your number pools and campaign IDs, and are able to segment your traffic by country from your traffic source with a URL variable.
Example Country Campaign IDs:
United States – Campaign ID: CA76996a75a6964ad7a37ba32c21e806e7
Canada – Campaign ID: CA44575a6911ad7ab7ba3f4gg94dg
United Kingdom – Campaign ID: CA111d55a6952az7437bass11gg94nn
Australia – Campaign ID: CA885b71a6964ad7a37ba3376gg94zz
Example Landing Page URLs:
Base – http://www.website.com/lp1/?geo=
United States – http://www.website.com/lp1/?geo=us
Canada – http://www.website.com/lp1/?geo=ca
United Kingdom – http://www.website.com/lp1/?geo=uk
Australia – http://www.website.com/lp1/?geo=au
Step 1: Grab country variable ‘geo’ from the URL using PHP
1 |
<!--?php $geo = trim($_GET['geo']); ?--> |
We’re using the $_GET[”] function to set the $geo variable with the value extracted from the URL, while using trim() to remove any extra accidental data. Our example does not correct for uppercase and lowercase data so you will need to make sure your geo= variable data is the same case as used below.
Step 2: Setup dynamic Campaign_ID insertion by ‘geo’ using a “Switch Case”
Now we need to set the Campaign ID dynamically by geo so we’ll use a ‘switch case‘.
1 2 3 4 5 6 7 8 |
<!--?php $geo = trim($_GET['geo']); switch($geo){ case "us": $campaign_id = "CA76996a75a6964ad7a37ba32c21e806e7"; break; case "ca": $campaign_id = "CA44575a6911ad7ab7ba3f4gg94dg"; break; case "uk": $campaign_id = "CA111d55a6952az7437bass11gg94nn"; break; case "au": $campaign_id = "CA885b71a6964ad7a37ba3376gg94zz"; break; default: $campaign_id = "CA76996a75a6964ad7a37ba32c21e806e7"; } ?--> |
We’ve set the default switch to the US Campaign ID. If there are any errors or missing data, the US campaign’s phone numbers will display.
Step 3: Dynamically insert geo Campaign ID using Ringba JS.
The last step to this process is making sure the proper Campaign ID is inserted into your Ringba JS code.
1 2 3 |
<div style="font-color: red; font-size: 22; font-weight: bold;"> <script src="//js.callcdn.com/dist/ringba.com.js?c=CA76996a75a6964ad7a37ba32c21e806e7"></script> </div> |
The ‘c’ variable needs to be updated with the $campaign_id variable we set in our PHP switch. We have 2 easy options to do that, a full PHP echo tag:
1 |
<!--?php echo $campaign_id; ?--> |
Your final Ringba JS tag will look like:
1 2 3 |
<div style="font-color: red; font-size: 22; font-weight: bold;"> <script src="//js.callcdn.com/dist/ringba.com.js?c=<?=$campaign_id;?>"></script> </div> |
Alternative JQuery Implementation Code
If you prefer to use the more robust jQuery implementation, your final tag would look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<script src="//code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script> <script src="//js.callcdn.com/js/min/ringba.com.js"></script> <script> // Campaign ID is echoed below: ringba.campaign('<?=$campaign_id;?>'); $(function() { ringba.getNumber({ // Tags can be specified by adding the tag:'value' and will be tracked for every impression. landingPageId:'testId' },function (numberPoolNumber) { // Phone numbers will be inserted into all HTML tags with the class 'phone-number' $('.phone-number').html(numberPoolNumber); },function(){ alert('Error function - Number not received.'); }); }); </script> <!-- End of Ringba.com Call Tracking tag --> |