More Advanced Uses of GTM and Some Big Query — CXL Course Review

kisholoy mukherjee
7 min readNov 15, 2020

In this blog, we will be looking into the ways of tracking user interaction with forms in a site, beyond just form submission. Secondly, we will see the use of tracker object, the most fundamental element in Google Analytics and how it can be used to send data. Thridly, we will look at how to set up Big Query for working on data from different sources. We will conclude by going through some ways to analyze data on this really useful platform.

Focus, Change and Blur

What this bit of Javascript code does is it allows you to see how many times your users have brought the Focus to a particular button field, how many times they proceeded to change the value of the field by entering some information and how many times they just shifted focus away from the form field. Simo also discusses how to track if a user has started moving away from the page even after filling a form but without submitting it. That is why the “beforeunload” event type has been associated with Event.action as abandonment.

Essentially what is happening is this: the callback function is being called whenever either of the events of focus, blur, submit, change or ‘beforeunload’ is happening. And this function is pushing the different attributes about the event like event name, EventTarget and event Action into the Data Layer for it to be picked up. This code can be put in the Custom HTML and a tag can be fired with an appropriate trigger.

Tracker Object

  1. Simple page view sent

2. Dimension added (once dimension is added, it just stays with the tracker and its value unless updated remains the same)

3. Mistake made: while creating an event value

4. Can specifically set the value of dimension and change it

5. Can pass data on events

6. Get dimension value by name of Tracker

This is an important point about naming Trackers. Since fields like custom dimensions are always set on tracker object and never on hits, it is important to note that if you set a custom name within GTM for a tracker, then there will be leakage of data from the page view tag to the event tag. In the image below you can see, that normally, GTM creates separate trackers for each tag to prevent leakage of data, therefore total number of trackers in the ga.getAll() is 6 [obtained by using the .length method] The leakage happens because the tracker names become same.

So even if some hitscope custom dimension fields were not set at the event tag, they will still get fired because they got leaked from the page view tag due to overlapping tracker names.

BigQuery — Importing Data

Next let us jump into BigQuery. It is an extremely useful tool that uses SQL to run queries on large datasets and carry out useful functions and operations on the data. One can also connect it to Data Studio for visualization.

Here are the steps for using it:

First table created under the dataset called Practice under the indicated Project name “ascendant-baton-295016”.

This was done using the Empty Table method.

JSON Schema code was used while creating this table. Here is it:

From Google Cloud Storage:

Create New bucket

Upload data

Must select “auto-detect” schema

Let us look at some introductory lessons on Big Query. It is basically nothing but querying data tables with SQL. A major advantage of Big Query is that one can import data from a number of sources including Google Analytics, one’s own computer, Google Drive and so on. Moreover, you can even connect the analyzed data with Data Studio and carry out analysis there.

First let us learn how to just create a simple data by entering data within the Query editor.

In the above example, we have used the “With-As” pair. We first simply created the new table by defining its columns and a single row by assigning the values directly. Then we just selected “All” with the “*” from the table to display it. Note that this doesn’t get saved and in order to do that, we have to follow the Schema route shown earlier or just upload a CSV file and so on.

Here is a very simple way to query a table by region and also order by it. Note how this broken-by-line form is obtained by clicking on Format Query for easy readability.

Note that “Where” is used on existing tables and not for custom created fields, like for instance, Total_Profit/2 (dividing a particular column by 2), i.e. before working with the data.

After working with data or creating custom columns, we can filter using “Having” clause but along with the “Group By” statement, as follows:

So as you can see in the screenshot above, first we have the “as” clause that helps redefine a column and transform into a custom column. TotalRevDivBy2.

But before the filtering using the Having, we have Grouped the columns.

Joining:

Now let us do a simple exercise of joining tables, because it is considered one of the main advantages of using SQL when it comes to use cases in digital marketing.

First, we will create the two tables from scratch along with the data. While creating the table, I faced a major challenge — for some reason, CSV upload method was not working. The field names were being automatically created instead of choosing the ones given. While I couldn’t figure out why this was happening, I was able to solve it by manually giving the field name inputs in the schema section. In other words, you can also edit the schema for a table created through CSV upload method.

This is what it looks like:

Anyway, these are the two tables.

As you can see, there is a common column/field in the two tables, viz. LastName.

We will be joining them by referencing this field.

And here is the end result:

This is just one kind of joining, Full Join to be specific. Many other kinds of Join are there. Right Outer Join, Left Outer Join etc. are some of the other types.

In fact, there are so many types of joins that it is best to show it using a Venn diagram:

Conclusion:

In the next blog, I will try to complete the BigQuery part so that in the one after that, I can take up either Excel or Data Studio. For GTM part, I will move on to the rest of Advanced learning by Simo which is really in-depth that is forcing me to study more on coding than expected. Game on!

--

--

kisholoy mukherjee

I am a digital marketing professional with over 6 years' experience and specialize in paid marketing and analytics along with creative writing