About cookies on this site

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. Learn more

Cookie settings

About cookies on this site

Cookies used on the site are categorized and below you can read about each category and allow or deny some or all of them. Learn more

Necessary

Some cookies are required to provide core functionality. The website won't function properly without these cookies and they are enabled by default and cannot be disabled.

Preferences

Preference cookies enables the web site to remember information to customize how the web site looks or behaves for each user. This may include storing selected currency, region, language or color theme.

Analytical cookies

Analytical cookies help us improve our website by collecting and reporting information on its usage.

Marketing cookies

Marketing cookies are used to track visitors across websites to allow publishers to display relevant and engaging advertisements. By enabling marketing cookies, you grant permission for personalized advertising across various platforms.

  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

October 31, 2017

How to Annoy Email Subscribers Less with Google Tag Manager

Note: this blog post was written a while ago. My current email marketing stack has changed, but the principles explained in this article are still valid.

I am constantly offering my readers to subscribe to Analytics Mania weekly newsletter. There are two types of tools that I use: embedded forms (by Omnisend) in each blog post and popups (by Privy). In the future, I plan to fully migrate to Omnisend, but this blog post is not about that.

Some of you might find popups irritating and, in some cases, I hate them too, especially, when I land on a website and a popup jumps right in front of me.

Dude, I have just landed. I have no idea what your website is about. Could I please at least take a quick peek of your site before you try to convert me?

I always try to practice what I preach, that’s why my email popup flow is a bit different:

  1. When a visitor lands on my blog, I wait a minute to show a badge which says “Subscribe to newsletter”. It is not very annoying and displays a subscribe form ONLY if a visitor clicks the badge.
  2. After another 60 seconds, I display a popup which suggests leaving an email address and get the Ultimate List of 120+ GTM Resources.

I don’t want to overwhelm my visitors, that’s why I ask for their email only after 2 minutes. Everything made sense to me until I received an email from one of my subscribers.

 

The Problem – email subscribers might be irritated

One day, I received an email. It was a reply to one of the newsletters I’ve sent.

Email from my reader

At first, I thought What do you mean? Later, all dots were connected.

Regardless of who the visitor was (subscriber or not), he was still spammed with my popup. Well, the word spammed is a bit too strong here because after you close it, the popup remembers this preference for another 30 days, therefore you’re not constantly annoyed.

On the other hand, nowadays, everyone has two, three, or even more devices that are used to browse, read blogs etc. If you close the popup on a smartphone, it will still appear if you clicked a link in Analytics Mania’s newsletter on a tablet.

So what can I do about it?

 

The solution

Some of you might say that I shouldn’t use popups at all. Well, that’s not an option for me. Popups work and they attract a significant number of new subscribers which let Analytics Mania grow (otherwise, no one would use them). So instead of getting rid of them, I need to adjust timing when they appear in order to reduce their annoying nature.

In other words, I have to stop showing email popup and badge for those who have already subscribed.

By the way, the implementation is fairly easy and … surprise surprise… it involves Google Tag Manager. Unexpected, right? I know 🙂 Who would have thought that I’ll write something about GTM in this blog.

So here’s the plan:

  • We need to identify visitors which land on my blog from Analytics Mania emails.
  • Those guys and gals will get a special cookie called amEmailSubscriber.
  • With this cookie, I’ll block email popup and Subscribe to newsletter badge.
Subscribe and Get the Ebook - JavaScript for Google Tag Manager

Identifying the current email subscribers

Every time someone clicks a link in Analytics Mania’s newsletter, they are redirected to analyticsmania.com/post/some-blog-post (or any other page). In addition to that, the link is decorated with 3 additional parameters, utm_medium, utm_source, utm_campaign.

Among email service providers, this using UTMs is really common. I could easily utilize them as a way to identify how that visitor was acquired.

On a regular basis, I send two types of emails:

  • Weekly newsletter. UTMs are:
    • utm_medium: email
    • utm_source: newsletter
    • utm_campaign: always different, depends on a content.
  • Welcome email which is sent after someone subscribes or wants to download one of my guides. UTMs are:
    • utm_medium: email
    • utm_source: automated_email
    • utm_campaign: welcomeletter

It will be pretty easy to identify email subscribers who clicked anything in a welcome email, there’s no other source of traffic with this set of parameters: email + automated_email + welcomeletter.

However, I might have some problems with the Weekly Newsletter. email as a medium and newsletter as a source is too generic and I need to think of something else. utm_campaign would be good but each week its value differs. My solution?

I’ll start using an arbitrary prefix in all my weekly newsletters as utm_campaign, analyticsmania_* . So instead of GTM Best Practices, utm_campaign will be analyticsmania_GTM Best Practices.

To sum up, all visitors who land on any page of my blog AND the URL contains either weekly newsletter’s or Welcome email’s UTMs will be considered as subscribers of my mailing list.

 

UTM variables and pageview trigger

First thing we need to do is create 3 variables which will retrieve the values of UTM parameters:

utm campaign source and medium

Then we’ll use them in two pageview triggers, one for visitors from Analytics Mania’s weekly newsletter and the second one from Welcome Email.

The first trigger will be initiated when:

  • utm_medium equals to email
  • AND utm_source equals to automated_email
  • AND utm_campaign equals to welcomeletter.

Pageview Trigger - Visitor from Analytics Mania Welcome Email

The second one will be triggered when utm_medium and utm_source are the same as in Welcome Email but the campaign is different, it must always start with analyticsmania_.

All my previous newsletters did not have this prefix meaning that this entire solution will work only for those subscribers who will click any link in the newsletter sent after November 1st, 2017.

Pageview Trigger - Visitor from Analytics Mania Newsletter

 

Let’s set the cookie

In one of my previous blog post, I’ve explained how you can easily set cookies with Google Tag Manager. Let’s use that very same code example with a bit modified values:

<script>
 
 var cookieName = "amEmailSubscriber"; // Name of your cookie
 var cookieValue = "true"; // Value of your cookie
 var expirationTime = 7776000; // 3 months in seconds
 expirationTime = expirationTime * 1000; // Converts expirationtime to milliseconds
 var date = new Date(); 
 var dateTimeNow = date.getTime(); 

 date.setTime(dateTimeNow + expirationTime); // Sets expiration time (Time now + one month)
 var expirationTime = date.toUTCString(); // Converts milliseconds to UTC time string
 document.cookie = cookieName+"="+cookieValue+"; expires="+expirationTime+"; path=/; domain=." + location.hostname.replace(/^www\./i, ""); // Sets cookie for all subdomains

</script>

Cookie’s name is amEmailSubscriber (“am” stands for “Analytics Mania”), its value is true and the cookie is valid for 3 months (meaning that if a subscriber will not click any link in my emails for 3 months, he/she will start seeing popups again).

Let’s create a Custom HTML tag which will set this cookie in visitor’s browser and we’ll do that ONLY when a visitor comes from Analytics Mania’s weekly newsletter or Welcome Email.

Set cookie - Visitor is email subscriber

Keep in mind that I’ve assigned both previously created triggers. If one of them activates, the Custom HTML tag will be dispatched.

Subscribe and Get the Ebook - JavaScript for Google Tag Manager

Test the cookie

It’s a good practice to do a checkpoint and test what we’ve done so far. Let’s save all changes, enable Preview and Debug mode, and go to the website. We need to add 3 UTM parameters to the link and refresh the page. That way the Custom HTML tag should fire, e.g.:

www.analyticsmania . com/?utm_medium=email &utm_source=newsletter &utm_campaign=test_campaign

If the tag did not fire (as in the screenshot below), make sure that all 3 UTM variables are created correctly. You can do that by navigating to the Variables tab of Preview and Debug console and checking whether all of them have some value, instead of undefined.

Custom HTML set cookie fired

After the tag is fired, we need to check cookie’s value. There are two main ways to do it – browser’s built-in feature (developer tools) or a plugin.

Personally, I am using Chrome extension called EditThisCookie (also available for Opera users). This really simple and intuitive extension enables me to quickly check which cookies are currently in use and what data do they contain.

If you haven’t, you can download it here. If you’re using a different browser, here are some similar plugins:

  • Firefox – Cookies Manager+
  • For Internet Explorer users, it’s recommended to use built-in features of developer tools.

Anyway, let’s get back to EditThisCookie. Once you have installed this extension, a cookie icon will appear next to the Menu icon (in Chrome).

EditThisCookie icon

Go to the website you’re currently working on, click EditThisCookie icon and you’ll see an expanded list of all cookies that are currently in use on that website. Look for a cookie named amEmailVisitor (you can choose any other name which suits your website) and see whether its value is true.

edit this cookie - amEmailSubscriber

Now, let’s proceed to the next step.

 

Updating popup’s tag and trigger

As I have mentioned in the beginning of this blog post, I use Privy for my popups. It’s installed by using a Custom HTML tag template and Timer Trigger with the following settings:

Basic Timer Settings

By default, this timer trigger will fire for all visitors regardless of where they came from and that’s where our cookie could come in handy. We could update it and set the trigger to fire ONLY when a visitor does not have an amEmailSubscriber cookie.

But before that can be done, we need to “teach” Google Tag Manager to read the cookie and turn it into a GTM variable. We’ll do that by choosing 1st Party Cookie as a Variable Type.

1st Party Cookie - Analytics Mania Email Subscriber

As for the Timer Trigger, we need to add an additional rule that will dispatch events ONLY for those visitors who are not my subscribers.

Updated Timer Trigger

Voilà! Now, I hope, my returning readers will be less irritated. To sum up, here’s how everything works:

  • When a visitor clicks any link in Analytics Mania Weekly Email Newsletter (sent after November 1st 2017) or Welcome email, they’ll be redirected the desired page with 3 UTM parameters: utm_medium, utm_source, and utm_campaign.
  • After he/she lands, Google Tag Manager will fire a Custom HTML tag which sets the cookie amEmailSubscriber: true.
  • Next time (within 90 days) when this visitor comes back to my website, the timer trigger (which launches a Privy popup) will not dispatch because the amEmailSubscriber cookie will block it.

I believe I’ve tested the implementation thoroughly but if you notice any bug, please let me know in the comments.

 

Drawbacks of this solution

There are two possible disadvantages of this solution you should keep in mind:

  1. If someone shares a link to my blog post (e.g. on social media) and it contains all 3 UTM parameters, those visitors will also not see the popup (even though they haven’t actually subscribed to my newsletter). Nevertheless, I still have a lot of embedded forms which can convert them, so this does not sound like a big issue to me.
  2. It does not solve the multiple-devices-per-user issue.

 

Conclusion: annoy email subscribers less with Google Tag Manager

So there you have it, another idea how you can leverage cookies with Google Tag Manager. Although this blog post is not directly related to Digital Analytics, it’s still very useful for Digital Marketers who are concerned about the experience of their visitors/readers/client/etc.

In this blog post, I’ve shared my idea (which I’ve implemented yesterday myself on this website) how to annoy email subscribers less with Google Tag Manager by adjusting the timing of when a popup must appear on the screen.

Instead of just showing it to all visitors after 1 or 2 minutes, I’ve decided to segment all my visitors into email subscribers and non-subscribers. Those who have already subscribed to my email updates will not see email popup for 90 days after their last click in my newsletters or welcome email.

Every time a new click happens, the expiration date of the cookie is extended to 90 days.

Julius Fedorovicius
In Google Tag Manager Tips
4 COMMENTS
Oleg
  • Nov 1 2017
  • Reply

That looks great, saved your article for further implementation!
However, it's kinda ironic that I found this article via newsletter link, and its utm_campaign doesn't match the pattern that you mentioned in the article, and therefore I still have the badge in the corner :)

    Julius Fed
    • Nov 1 2017
    • Reply

    Yes, my bad. I forgot to add the prefix "analyticmania_" to utm_campaign. Next time I'll need to be more careful. This was just my stupid mistake :)

Tatiana
  • Feb 6 2023
  • Reply

Hi Julius,

Thanks for the article. Just one question, why did you choose the 1st party cookie over storing the information in the localStorage of the browser?

    Julius Fedorovicius
    • Feb 6 2023
    • Reply

    No particular reason. Localstorage is also fine. But keep in mind that the same cookie can be accessed by multiple subdomains. Localstorage can be accessed only on the same subdomain.

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Google Tag Gateway: What is it, and How to Configure it
  • Google Analytics 4 User ID for cross-device tracking: how to configure it
  • How to Track Clicks with Google Analytics 4 (2 Options)
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings