Analytics Superpowers with and Google Tag Manager

By Arun Sivashankaran

analytics, google analytics, google tag manager,, tools

Analytics plays a critical role in improving conversions in several ways including exploratory analysis and ongoing reporting.  One of the main factors that can constrain your ability to optimize your site for conversions is the quality of the data you have available and your ability to act upon that information. There are an amazing array of web analytics solutions available to the marketer these days, but too often they’re underutilized in the face of other business priorities or technical and setup complications. That’s a gap in the analytics architecture, which  is just as important as the product architecture for online business.

Photo Credit: Apreche via Compfight cc

This isn’t just a technical problem, there’s a significant organizational challenge as well. Savvy marketers who can interpret data invariably want more – better insights into customer behavior and  tools that can deliver it. The burden of responsibility however frequently falls on already overworked developers to implement the tags and tracking code necessary to accurately collect that data. The general solution that has emerged to deal with this challenge is tag management – from free solutions like Google Tag Manager to enterprise platforms such as Tealium and BrightTag. At FunnelEnvy we love Google Tag Manager, but we’re also fans of – a company that approaches the same problem from a different perspective. They wrap all of the analytics providers into a single set of consistent APIs (server, Javascript and mobile) and allow you to “turn on” new providers through a simple interface.

Like any solutions both tools have their benefits and drawbacks, but it’s possible to combine the two into something truly awesome.

About Google Tag Manager

Like many tag management solutions, Google Tag Manager allows us to extract all of the marketing tags, pixels and analytics calls that we make out of the app, and into a user interface that let’s a marketer manage analytics without requiring code change to the website. This has several benefits, including:

  • Speed – Instead of bothering the developers to make our analytics changes we can implement them directly in Google Tag Manager.
  • Flexibility – Google Tag Manager’s concepts of tags and rules gives us a lot of flexibility to define what runs where.
  • Data Access Consistency – By standardizing macros and using the data layer we’re able to have a consistent approach to retrieve important data from the application.
  • Version Control, Preview & Debug – Google Tag Manager uses a container based model that allows us to visually preview, debug and rollback analytics changes.

Although Google Tag Manager has a few built-in tags for certain providers (letting anyone without coding experience implement a provider) we don’t really use these often since the current list of built-in tags is somewhat limited and we’re pretty comfortable writing Javascript.


As a developer turned marketer I’ve been a fan of for a while now and instantly saw the benefits when it first crossed my radar. We deal with a lot of analytics solutions for our clients, and rather than having to implement tags and calls to each specific one we can just make calls using the open source analytics.js wrapper and handles sending it to whatever providers are enabled. They provide a really intuitive interface to turn on / off providers, and have a great solution for storing data and “replaying” it onto a new provider. The new Live Debugger that they’ve introduced is a great step forward for testing, and it’s  an even more effective solution for native mobile apps, since enabling new analytics platforms doesn’t require a recompile.

By default with you’re still embedding code into the application (although probably less than you would without it), and it doesn’t (yet) have the concepts of rules, macros / data layer, and container management that Google Tag Manager brings to the party.

Best of Both Worlds

When I saw that had introduced support for Google Tag Manager I wondered if it would be possible to combine the two. The idea was to use to instantiate Google Tag Manager as a provider, and then make calls to from within GTM.

There’s something circular about this approach –  using to setup Google Tag Manager and then using GTM tags, and rules to make calls to the API. This allows us to have some of the flexibility and container management that Google Tag Manager has, but still keep the consistent API and provider management of After trading a couple emails with Jake Peterson from (who assured me that attempting this would not cause another polar vortex), I gave it a shot.

Step 1: Install code Code

If you’re using WordPress you might want to check out the plugin that makes this easier.

Step 2: Setup a Google Tag Manager Account and Container

Head over to Google Tag Manager and setup a new account and container. Don’t put the GTM <script> tag on your site, you’ll set that up in the next step.

GTM Container

Step 3: Turn on Google Tag Manager within

Head over to your integrations, and turn on Google Tag Manager. You just need the Container ID that you created in Step 2 here. GTM provider

Step 4: Configure, Debug and Publish your Tags

At this point you can create your tags within Google Tag Manager. For any tags where you’ll be using you’l want to to use the Custom HTML Tag Type. Here’s a relatively simple example that fires a virtual pageview using and also uses the rules and macros of Google Tag Manager.

In this case the app is giving us data  (the virtual pageview to fire) by using the data layer. In Google Tag Manager we pick that up by using a macro.



In order to fire the tags, we have to create a rule that checks the event value in the data layer:


Finally we associate the tag for the virtual pageview with the rule. Note that this is a custom HTML tag that uses the API:


It turns out to be really straightforward. Many of our tags in Google Tag Manager are Custom HTML tags that call, but that’s not an absolute requirement. You could easily combine this with built-in tags, and still use the data layer and macros approach. Obviously this is a relatively simplistic example, but it’s easy to imagine using approach to better manage a more complex analytics architecture. Where this solution could be particularly valuable for is in situations where there are multiple analytics providers being used, and where you expect to be making significant changes to the analytics code.

At some point I suspect these solutions are going to converge and this sort of approach will no longer be necessary. Google Tag Manager is rapidly adding more built in tags, and if the Live Debugger is any indication will also introduce more of the features of traditional tag management. But as an interim solution for those of you who want the benefits of both solutions this may be an approach worth considering.

Do you have any suggestions for dealing with rapidly changing analytics requirements? Let us know in the comments below.

Improve your Conversion Rates with FunnelEnvy

From research & analysis to test and campaign development our optimization engineers will get your conversions headed in the right direction.

Learn About Our Services
  • Ryan Tyler Smith

    Great article. Just what I was looking for!

    • Arun Sivashankaran

      Thanks Ryan – glad it helped!

  • Adrien Beata

    Hi Arun,

    Thanks for this very interesting article.

    Do you use only analytics.track to push data in GTM dataLayer ?

    Thanks in advance for your answer.


    • Arun Sivashankaran

      Thanks for reading and the comment Adrien.

      In this approach’s analytics.track is still used for it’s standard purpose – to send a user event though to the underlying provider. What we’re trying to accomplish here is to give us some more flexibility in terms of deploying these tags and using a consistent interface. Hope this helps!

  • Edward Upton

    Great idea. One of our clients is interested in using as an intermediary – so they could use the ‘replay’ function to import into another data store in the future. But the downside from my perspective is another level of complexity / point of failure in the data capture.

    • Arun Sivashankaran

      Thanks for the comment Edward! I think the fundamental “theorem” of software engineering is applicable here (any problem can be solved by an extra layer of indirection). Of course as you note each of those abstractions introduces another moving part that can break – so they need to be appropriately justified against the business requirements. There have definitely been instances where I wished I had the replay feature available, generally when I want to do retroactive analysis in a different platform.

      • Edward Upton

        Yes, replay feature seems great – although it does rely on the new platform having a good historical import function and matching user IDs etc seamlessly. With GA that’s obviously impossible, and from experience with Mixpanel and Keen it’s not simple.

        • chriscls

          Great article Arun! I work at Segment and love seeing how the tag management space is evolving. Edward, you’re right regarding the ability of the end tool to accept historical data. Let us know if you need any specific questions reg playback (, we’ve helped quite a few people move around and happy to answer any technical questions.

          • Arun Sivashankaran

            Thanks for the comment Chris! Keep doing great work over there.

  • Rodrigo Campos Paiva

    Hi Arun. I would like to know if you still using this approach and if there is some speed issue with that. How the events are sent if the user move fast to other page/website? I as that because I’m worried with data lost. Thanks

    • Arun Sivashankaran

      Hi Rodrigo – thanks for your comment. I’m actually not really using this approach much anymore, but the reasons don’t really have to do with data loss. You’re right to be concerned about it – if you fire analytics events in the onClick handler of a link (for example) you could very well be in a race condition and lose some of those events. That being said both Google Tag Manager and Segment handle this situation pretty well (last I checked) and insert a small delay so you *should* be ok. Also it’s important to keep in mind that any analytics implemented on the client side is better looked at as a directional measure rather than the absolute truth, because in addition to race conditions you’re going to have people who block Javascript or specific analytics platforms.

      Hope this helps!

      • Rodrigo Campos Paiva

        I’m curious about why you don’t use this approach anymore. Could you tell us?

        I’m using different tools to track user data and I’m trying to simplify this process (web & app). Do you have any suggestion/advice?

        • Arun Sivashankaran

          Sure Rodrigo. The real reason I’m not using the segment part of it as much anymore is that it really doesn’t fit our use case as much anymore. As a third party dealing with other companies analytics we don’t have the ability to push any production code and we’re not really adding many other platforms, so tag management solutions alone are often sufficient for what we do. That being said segment is a great product and smart team with some really compelling use cases – it’s just not what we need at the moment.

          I’d need to know more to offer any concrete advice on your situation. Feel free to drop me a note using the contact page here.

          Thanks again for your comments / questions!

          • timframed

            Appreciate the insights here Arun. We were recently thinking to implement this structure and wanted to get your thoughts (non-technical here, so thank you for your help!)

            – Create Twitter + Facebook social display accounts and generate tags
            – Add display adds to GTM container
            – Take GTM snippet and add to website + webapp pages
            – **We do want to use Segment as well, but this would be for a larger over-arching project that also takes into account in-application analytics.

            ^I suspect this last step is where you might have pulled out as well since it touches more production code?

            For our particular use case, our most important thing is to start running some display/re-targeting ads and track conversions (which I imagine GTM reports to GA nicely).

          • Arun Sivashankaran

            Thanks for your comment / question. Without knowing more it sounds like you’re headed down the right path. It’s important to keep in mind that GTM is really just a vehicle to make it easier to fire tags and manage them (along with associated triggers & variables) in a more structured way. So with GTM you’ll be able to fire your events / pageviews to GA in order to track conversions.

            Hope this helps.

  • William

    Just wonder why not setup within Google tag manager? We would like to use GTM to fire pixels while using to collect data for later use. Would that be possible?

    • Arun Sivashankaran

      Hi William – yes that’s what I’m describing here in this post. It seems to work well and if it meets your use case go for it! Thanks for commenting!

      • William

        Hi Arun – thanks for your comments. Maybe I’m not so clear about my question. I would like to use GTM as the container pixel for, so there is no code embedded in website at all. All we need to do is just configure it in GTM to use Would that be possible?

        • Arun Sivashankaran

          Thanks William. Now I understand the question, thanks for the clarification (I wrote this a while back :). Yes, I think you should be able to use GTM as the container for the segment code – though I haven’t tried it myself. The thing to remember is that GTM tags fire asynchronously, so you may have to control the dependency order of your tags.

  • James Haren

    Nice work! I had a good experience filling forms online and happy to share it with you. If you ever need to fill out a form, here is a really useful tool. Very easy to navigate and use.