Taking your Google Analytics Skills to the Next Level with a Basic Understanding of JavaScript and the Data Layer
If you think JavaScript and the Data Layer sounds like an awesome band name, then you might just be dorky enough to keep reading this blog post. Or if I’ve lost you already, give me a second chance and keep reading anyways. As a marketing analyst, I am always looking to improve upon my skills. Knowing GA (Google Analytics) and how to interpret data is one thing, but being able to track website properly so that useful data is flowing into GA is completely different. This is something I didn’t understand when I started out as a marketing analyst, but the more time I spend in this area the more I realize just how much there is to learn in order to turn myself into a great analyst. In this post, I am going to introduce you to both JavaScript and the data layer, and explain why getting to know these two elements of website design is critical to effectively analyzing your marketing efforts.
JavaScript – What is it? Why is it important? How do we use it? How do we learn it?
JavaScript, by definition, is a programming language, just like Java (yes, it’s different), Python, Swift, and Ruby. Along with HTML and CSS, JavaScript gives us the solid foundation of our website. HTML provides the structure of the site, CSS controls the look and feel, while JavaScript controls the behaviours of the different elements.
When someone clicks either the “Yes” or “No” button (for example), JavaScript produces the “If….Then….” statement to determine what will happen next. It will then pass this data to third-party tools like Google Analytics and Google Tag Manager. Also, just for interest sake, it’s good to know that both Google Analytics and Google Tag Manager are built in the JavaScript language. When you are adding those codes to your website, that is JavaScript. And because those tools are built on JavaScript, they provide customizable features that one can use if they know the language. If that’s not reason enough to get to know this language as an analyst, I don’t know what is.
So, how do we use it? While knowing how to write JavaScript is super useful when using a tool like Google Tag Manager, I don’t consider it mandatory. That would be taking your skills to another level. What is mandatory as an analyst is being able to read JavaScript and understand the basic principals of the language. Once you know this, you can better understand how to set up variables, triggers, and tags to help feed very useful information into Google Analytics. There are many ways to learn this programming language, but my suggestion would be to head on over to Code Academy, sign up for a free account, and take the Introduction to JavaScript course. This will give a foundation to start digging into the website you are tracking and pulling out elements of the site you didn’t realize you were able to track.
The Data Layer
Pulling out these elements leads us to a discussion on the Data Layer. The data layer is a JavaScript variable or object that holds all the information you want to collect in some other tool, like Google Tag Manager (Cutroni, Make Analytics Better with Tag Management and a Data Layer, n.d.). It’s the common language between developers, marketers, and analysts, and is what allows us to identify events occurring within the website.
What information is available in the data layer? For any website, identifiers such as Page Title and Page URL are common. Visitor information can also be pulled from the data layer, like visitor type or visitor value. Transaction information can also be set up, such as Page Category, Product Name, Transaction Total, etc. Information is either written into the data layer as part of the page code (via a website developer), or it’s pushed to the data layer later as certain events occur. The information may vary by page or may change depending on a visitor’s actions (Lunametrics, n.d.). Once the data layer is created, you can then create Events to fire as actions on your website take place, such as a button click or a PDF download. These Events are then fed into Google Analytics for you to analyze.
How do we use that information? Obviously, figuring out the “how” to all of this is a different discussion. It all depends on how the website is built, how the data layer is being populated, and what the business goals of your client are. As you can imagine, the “how” becomes a case-by-case scenario. However, if you arm yourself with the right tools – such as learning JavaScript and how the data layer of a website works – you can start to experiment within Google Tag Manager with creating custom variables and tagging different elements of a site. Once you are able to start playing outside of the box of GTM that’s when you become a real analytics rockstar!
What are your experiences with JavaScript, Google Analytics, Google Tag Manager, and the Data Layer? Feel free to share your experiences and any tips and tricks below!