The complexity of implementing Google Analytics

Julien Kervizic
Hacking Analytics
Published in
7 min readJul 22, 2019

--

There is more than just placing a small snippet on a website to implement google analytics. There are different integration patterns to capture the data into Google Analytics, and each integration is subject to a lot of pitfalls and potential regressions needed to guard against. There are also question as to whether or how to use the different APIs provided by GA.

Integration patterns

Besides using a hardcoded implementation of Google Analytics, there exist three main integration patterns for tracking data using a tag manager and pushing it to Google Analytics.

Scraping & event listener

One of the potential integration patterns for Google Analytics, is around scraping information on the website, typically through calls on the Html Dom, but also through extracting data from URL structures, as well as pushing some event listener to capture user’s interaction with specific components on the website.

When going for this type of integration pattern, it is typical to enhance the information already available on the website with data attributes. Essentially hidden information added to the different elements on the HTML page that allow for surfacing these pieces of elements to google analytics.

<ul>
<li…

--

--

Julien Kervizic
Hacking Analytics

Living at the interstice of business, data and technology | Head of Data at iptiQ by SwissRe | previously at Facebook, Amazon | julienkervizic@gmail.com