Analytics integration is bad

To avoid starting with an insult

Analytics implementation is one of the tasks to be done as a Front End Developer when it requires more than view or click events to be registered. But it is one of the tasks I despise the most.

Why? This should be a trivial thing to do but it isn't. For example, several tools want the same data but implement not the same structure. And when you are working on locked-in CMS, you are facing situations where you need more data than supported by default: you need to do more requests via different APIs to get what you need.

You are doomed to include several methods: sending the same data to different services in different forms. This is adding more and more bloat in your codebase.

The events can be unreliable on complex applications, and your client can complain but this is not your fault: tracking companies don’t always provide a good enough SDK or one at all. On top of that, most of the time the documentation is imprecise or not updated. We are losing time to implement them. And if you are working on a headless project, you will encounter more problems than anyone else.

GTM is the solution right?

For those unfamiliar with Google Tag Manager (GTM), it's a Google tool that lets you manage tags and send data to other platforms without editing your site's code. But most of the time, to have access to specific data, you will have to expose them through your code. On top of that, some tools cannot rely on GTM because they need deeper integration with customer sessions. This can be done via GTM but it can add a layer of complexity to use this kind of setup with GTM since it was not designed to handle this kind of task.

Padme Anakin Meme

GTM is a great dispatcher for simple events, but when you have complex data or external tools requiring deeper integration, you are quickly limited and need to do custom code.

Debugging hell

The mysteries of bugs from tracking data are so complicated. When everything works, you are happy but when your client is calling you because he has mismatches between the sales on their e-commerce and on their Google Analytics, this is the end of the fun ride and a harsh return to reality.

So, how and where to find the issues? Most of the time, you need to look at the network panel (in the browser dev inspector), and check if GTM or Klaviyo sent an event by filtering the request. You can also add a breakpoint or a console.log, to directly look at the data layer object in your browser. This will allow you to see if everything is structured and sent as wanted.

Sometimes, you have browser plugins or widgets (via a secret parameter) allowing you to see what the tracking lib tracks.

But, with the complexity of the web (devices, browsers, user flows...), some bugs are hard to understand or fix.

CDP for the rescue?

I was not aware of CDP (Customer Data Platform) until doing this blog post. But this is a cool solution on paper. You are sending your events data to a server and it will be redistributed to all the platforms you want (data warehouse or any kind of services, analytics solutions included). There are proprietary libraries like Twilio Segment or open source ones like Jitsu.

But we are facing the same issue as GTM: these solutions are not designed to handle deeper integration tracking tools. They are good to collect data and share them with other tools, that's it.

Don't forget GDPR

If you live in the EU, we eat GDPR rules every morning with our cereals. Most of the time, I use Axeptio but I can also quote TarteAuCitron or OneTrust for example.

I don't have any issues with most of these solutions, they are doing their jobs providing a widget and asking for user consent. The problem I have, is with the implementation on the analytics side of things. On the good side, we have companies integrating easy options to connect with your CMP: this is allowing a quick and easy setup.

And on the other side, we have to manually set the consent via the library or worse, by adding a cookie to disable the tracking (because it is on by default, that's what analytics solutions do).

In the end, you are getting a website with several methods, data and, to finish, different methods to manage the consent. Your code is now a beautiful mess.

Hell of fame

  • HubSpot: Seems like your page is not heavy enough
  • Clarity: Same performance as mining Bitcoin on your browser
  • Piano Analytics: terrible documentation, a doctorate degree to understand the privacy part
  • Klaviyo: Thinks headless is a character in a Tim Burton movie, and says one thing and another on their documentation for the same thing...
  • GTM: it just works until it doesn't

Don't take it personally, if you felt targeted 😄


Companies ask for more and more data than ever to watch what their users are doing to improve their selling performance. Furthermore, I don't see in the near future ways to facilitate the integration of analytics tools. We should have proper documentation and SDKs, ready to use and I dream of a common format, especially on ecommerce where the same events are always triggered (add to cart, purchase...). Ecommerce CMS provides great default integration but clients want more and more tracking data to better know their users. Custom solutions want custom implementation.

Currently we need to adapt to what tools we need to integrate and do our best. So, doing your little adapter in JavaScript to trigger GTM, Klaviyo and Nosto for the add to cart event is totally okay and there is no better solution.

Did you enjoy this article?
You want to say something about it?