[How-to] Geo-Target Convertables with Google Tag Manager


#1

TL:DR Target pop-ups based on Country, Region, or City

If you’re like me, one of the first things you wanted to do once diving into the new embedded CTAs was Geo-Target them based on segment. Well, you’re in luck as I’ve spent all morning researching the perfect setup, and it’s all yours to implement!

This process uses Google Tag Manager + Unbounce to achieve the segmentation. If you don’t already use GTM (?!?!) you can easily find resources online—you’ll need it though as it does half the trigger process.


How to Install in Unbounce

Click Here for Instructions

:rotating_light: WARNING: YOU ARE ENTERING DEVELOPER TERRITORY :rotating_light:
This is not an official Unbounce feature. This functionality is based entirely on third party code, and has only been tested in limited applications. Since this isn’t a supported Unbounce feature, our support team will be unable to assist if things go awry. So if you are not comfortable with HTML, Javascript and CSS, please consider consulting an experienced developer.


Step 1: Create a New Tag in GTM
In the ‘tags’ section create a new Custom HTML Tag with the script at the end of this article. This will take the user IP, run the data through GeoPlugin and then push the variables to the Data Layer in GTM. Make sure this fires on all pages you need to use geo-targeting on.

Step 2: Create the New Variables
Each of the three variables (Country, Region, City) will need to be setup as a new datalayer variable in GTM. In the variables tab hit ‘new’ and add three elements. Repeat the following as three new variables:

  • Variable ‘Country’
  • Variable Type: Data layer Variable (Page Variable)
  • Data Name: ‘country’
  • Layer Version: Version 2

Step 3: Create Your Trigger (Per Unique Event)
Under trigger, create new:
Trigger Type: Page View – Window loaded
Trigger Fires on Country contains “Canada”

Step 4: Input Unbounce Script
Finally, the only thing left is to create a new tag and select your new trigger


UPDATE 1
Having multiple tags firing on the same page do conflict with one another. Tomorrow I’m going to try and sort a workaround.

UPDATE 2
It appears as though the script for ECTAs is actually the same for as many as you make. This means, while geo-targeting can work, you can only have one per URL running.


SCRIPT FOR TAG:

<script src="http://www.geoplugin.net/javascript.gp"></script>
<script>
  (function() {
try {
var city = geoplugin_city();
var country = geoplugin_countryName();
var region = geoplugin_regionName();
dataLayer.push({
'country' : country,
'city' : city,
'region' : region
       });
} catch(e) {
        dataLayer.push({
          'event' : 'Error',
          'Jserror' : e.message
        });
      }
     
  })();
</script>

Can’t see the instructions? Log-in or Join the Community to get access immediately. :rocket:


Want to take your Unbounce landing pages + Convertables™ to the next level?
:spinbounce: Check out the Ultimate List of Unbounce Tips, Scripts & Hacks


[Feedback Wanted] Popups
#2

@colinsa This is AWESOME!! :clap:


#3

This is really exciting! Thanks for sharing this.

We’ve been recommending using GTM as a way to preview and test your ECTA on a live site. We hadn’t look at it to support segmentation, so this is super cool.

FYI: we are looking to add geotargeting, along with other visitor targeting methods, directly into ECTAs in the near future.


#4

How soon? I’d love to help alpha/beta test this with our hotels. the GTM method, while still valid, I have determined only works with one tag per unique URL.


#5

Hi @colinsa
I’m not sure if it helps, but one thing that you can do is to differentiate your ECTAs by query string parameter. If you can set a query string parameter through the geoplugin code, you can set up a contains include rule to look for that query string parameter value for the corresponding ECTA.

So for example, if you have 2 ECTAs with the following contains rule:

  1. ECTA #1 w/ Canadian content: Include on URLs that contain “country=canada”
  2. ECTA #2 w/ global content: Include on URLs that contain “country=global” or Include on all URLs, Exclude on URLs that contain “country=canada”

Then within geoplugin script attach the country variable value to a URL querystring parameter. It’s potentially an extra redirect, but I think that it should achieve what you’re looking for.

Does this help?


#6

This does help, thank you.

I have been testing a similar concept in our hotel booking engine with regard to rate-codes. I can use the URL promo=x or similar string. The only part I am not sure of is how to have this pushed to the URL directly.


#7

This is great!
Been waiting for OptinMonster to come up with Geo targeting - but it’s taking them forever! Going to give this a try once the turkey leaves the body.

Btw, what’s an ECTA?


#8

Hi @Mark_H,

ECTAs (Embeddable calls-to-action) are a new feature that we’re working on here at Unbounce. We’ve just released the feature into Labs and have just started letting customers know about it. If you’d like to try it out, feel free to go into Labs (Under Settings > Lab Features) and turn it on.

We’ll have a top level post going up in the community later this week about the feature!