Google Tag Manager Cookbook | Chris Worfolk | Skillshare

Google Tag Manager Cookbook

Chris Worfolk

Google Tag Manager Cookbook

Chris Worfolk

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
6 Lessons (18m)
    • 1. Welcome

    • 2. Custom dimensions in Google Analytics

    • 3. Google Analytics User ID

    • 4. Track events with Facebook

    • 5. Install click tracking with FullStory

    • 6. Use if statements with variables

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this class, we'll learn how to complete some commonly-requested tasks using Google Tag Manager (GTM). It is a follow on from my original Google Tag Manager course, so it is recommended you complete that class first in order to understand the fundamentals.

We'll learn to:

  • Use custom dimensions with Google Analytics
  • Integrate Google Analytics User ID
  • Track events with Facebook Pixel
  • Install click tracking with FullStory
  • Use if statements with variables

Meet Your Teacher

Chris Worfolk is a psychologist and software consultant. He is the author of How To Exit VIM and Do More, Worry Less.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Welcome: Welcome to this course on Google Tag manager recipes. This my second Google tag manager class on the two go hand in hand. So the 1st 1 looked at the fundamentals of use in Google Tag Ninja and this one will give you recipes to a lot of common problems. Common things you might want to do. I'm Chris, your instructor, and I'm really excited to have you here, so let's get started. 2. Custom dimensions in Google Analytics: in this lesson will look at how to use custom dimensions in Google analytics and link that up through Google tag manager. So first, let's talk about what a custom dimension is. It's an additional variable you want to measure. So, for example, on this website I've got here I'm using to custom to mention some using variant and adverts and sometimes we a B test pages on. We also a B test adverse to see which one's the best on. So we've got these variables to track and then, under reports, we can then generate reports based on which paid to the user is seeing on which one is converting the best. So let's look at how we would set this up if we wanted to add these custom variables to our own project on here. I've got our example that we've bean working through and forget into admin, and if we were on the property section here and if we go down to custom dimensions, you can select custom dimensions here. That's at a new one. So let's say we've got multiple adverts and we want to track what advert the user is coming in on. Well, just called advert on and will make it for the session because they might see a different of an accession. Wonder it's it create just done that on. And the important thing we need is this index is one. Okay, great. So here we're back in our Google tag manager and we'll go into our example project. The first thing we'll need is to create variable, and it's gonna be a user defined variable, and this is gonna be so someone clicks on an advert. Andi, let's say it's ah javascript variable. So we're gonna get the advert, Maybe from the oral. We could digits grab it straight from the u R L But in our website, we're gonna save it to a job script variable called advert. So in our code will create this variable called advert On. Now we've brought in as a user defined valuable into Google tanks. Now all we need to do is link this variable up to how ah, Universal Analytics in here. So here are Google Universal Analytics. Now, this is our main tag. It's not any kind of event. It's just where we're loading Google analytics in via Google tag manager on its the settings that we need to mess with. So what we did here is when we created Google Analytics, we said, Let's use these Google Analytics settings on these settings on themselves. Variable says Go back to variables. Now it's useful to show how we trace it through. And we've got this Google analytics settings on wherever we use a Google Analytics tag, we're going easy settings and what is going to edit this configuration? And we got two more settings and we've got here custom dimensions so we won't add a custom dimension. And the first thing assets for is the index. So you remember when we set this up, it gave it an index for one. And so that's what we want to enter here and then dimension value. We've just defined this variable advert, so we're gonna set it to advert. That's all we do is save and then we get So let's just go through that again. We've defined this user defined valuable called advert. We could take it from you, r l from a cookie from the job of scriptures we've done here. However you want to feed in from your website, we're then going into the Google analytics settings that you remember were using from the Google Analytics tag and in the Google Analytics settings with setting this custom dimensions were using the very voyage it's created, and we're telling that popular index one, which is the index that we've also created in Google Analytics. 3. Google Analytics User ID: in this lesson will look at how to use the Google Analytics user. I d feature aunt had a link this up via Google tag manager. So user i d is great for If you want to track user interactions across multiple sessions or multiple devices, you can send Google analytics a user I d on, you know, do that. First thing we need to do is to enable it because not enabled by default because of certain privacy issues around it. You need to make sure you're getting users permission on that. You're doing it in an anonymous way. So the first thing we want to do is go into settings on under the property. Going to tracking info on down to user i d. As you can see, it's not enabled by default, so we need to read through this. Agreed to the policy? Well, that's fine. I don't need to create user. I d view now said it Anyway, fellas, cancel that. We go back into tracking phone user I d. It should now be enabled. Yeah, so we don't need to change that tracking code because we're doing it through Google tag manager. The important thing is that we have now enabled it on. We can then go set it up in Google tag manager, and we do have this custom I d used find variable. But customer I d. Is sort of anonymous, maybe know what we really want for the analytics is to create some kind of anonymous tracking I d. Because we want to be able to link up user behavior. But we don't really want to be able to trace that back to the user because there's all kind of privacy implications about that. So instead, maybe alongside the Coast mighty, we create a tracking I d. That's just a random string that nobody in the content management system could trace back to a specific user account on. Let's assume that was saving that as a cookie as well. So we'll go in or get a new variable on. And let's say we're calling it tracking I D. So every user gets a tracking I d. That's just anonymous strength that we don't put in the CMS, and we'll call it customer tracking. I d. Okay, great. So not be populated for a cookie that will set on our website and then again. We need to feed that into Google Analytics now. As you might remember, when we set up the tag, we've put all the settings in this Google Analytics settings variable. So let's get back to variables again and find our Google Analytics settings. Here we go, Andi, let's go in and edit again. And this time we want to go to this more settings and fields to set we want at a field that we're gonna call user I d Who and then we're gonna set the value as customer tracking i d and hit save. And then we have it. So when we insert Google analytics and we using settings, we're now setting this field name of user I d to the customer tracking I. D. 4. Track events with Facebook: in this lesson. I want to take you through sending on event to Facebook. If you've already done my fundamentals lessons, then you probably have already seen this. But just as a quick recap or recipe for those who are coming to this fresh, then let's go through the process of how to do that. So the first thing we need to do is create our Facebook pics or on, and we've already done that here. So it's a custom Hoekstra mail on. We just dropped the pixel data into that. Next thing we want to do is create a trigger. So when are we gonna fire this on? Let's create one for the confirmation page. So after they get through the check out on and we'll make this a page view event. So when someone loads a page on the U. R L. The path wants to be, say, check out, complete. When someone lands on this page will know that they have successfully checked, checked out, finished the check out purchase something. Andi, let's go. Let's check out complete page. Next thing we want to do is we want to pull the amount of spent out of the Dome said. To do that, we're gonna create Use it to find variable on, Let's say, take a dom element. So there's a bunch of ways you could do this on ideas. Fine. So you might just set it is a data layer variable if we have been previously. But also, you might just have an element that says, like, total price on with an i d of total price. And if you just got that element in the page, then you can just go out and select it. Using the idea of total price. I gotta tell Price Dom Element that will search the page, find the piece of hates Gmail with the idea of total price and pull out the attacks. I think it would be better to set it as a day of variable budgets because we did that in the fundamentals lesson. I want to do something different this time. Okay, so we've greater trigger we've created are variable. And now we need to go create attack. So in this case, we're gonna is gonna be a custom html tag on. Some jobs could weaken drop in here, so we know. Call the Facebook. Maybe I and track purchase on for this value, we're going to use the variable that we just created, which wasa till five star melon Andi on a shipment yearning selling in one currency. Let's call it euros here. Okay, so that looks good to me. So now happens is not set triggering as well. On it was this check out complete page. It was just created. So now when they use that hits this check out complete page, then it's gonna run this script. It's gonna pull the price out the dumb. And it's going to send that as a purchase event to Facebook. Andi. A couple of other things we want to do. So it's up to once per page it and really matter there and also in tax sequences. We want to make sure that the Facebook pixel tag fires before we try and send an event because it would try and send an event. And we haven't loaded the pixel yet. It's going to explode on, then save that So Facebook pick so purchase events, and that's dumb 5. Install click tracking with FullStory: in this lesson, we'll look at how to install some kind of click tracking software, such as we need full story in this example. We could also be using Hajar or Crazy Egg or inspect lit. And to do that, we're gonna get the tags on. This is it's gonna be really easy going to get it new on in town configuration if you are using crazy egg. I think there's a pre Veldt one here that isn't for full story, which means we're going to need to do this. Custom hits Jemele option We're going to go into full story, get the settings on on that copy and paste our code God being placed into here on. Let's set this to run on all pages. Given the name full story, save super simple, it juts a hipster mail custom tag. And whenever you just get a piece of script that doesn't have a pre built template, you can just paste into that crypt. Some hates him out, and that will do the job for you. 6. Use if statements with variables: What if we wanted Teoh use? Um, if statement to have in tax Well, we can do that. So, for example, in the previous lesson, we installed a click tracking software Full story and one of their features of full story is that you can link them together sessions using some kind off, use a tag. So let's look at how we might do that and how we must conditionally do that. So we're gonna create a new tag on It's gonna be a custom Hegstrom Altech. Andi, that's get rid of this because we don't have this for the moment. So all we do in who is calling full story A p I and will say identify this as a user. I d thinking this. We've called it custom I D Yep. So now that will tag this customer I d for all the sessions in full story. And let's set up some tax sequencing on that. So before we fire this tag, we always want to fire the full story tack first ongoing struggling to all pages. So now not only are we gonna load the full story tag, but we're also going to call this to tell full story that this should be linked to this customer. I d. That's got his full story custom. I d. Okay, Super. So this is kind of fine. But if we look at what we've done here, then what happens if this custom idea is actually blank, then full story might be able to handle it. But it might know what we really want. If detract that this custom I d has a value before we run this script, and we can do that by just I'm making the job script, putting that into the job script just like if we were writing job script on a website we can use. If statements on we can use the variables inside it as well. So let's say, if customer I d. And it's literally a simple of that. We just writing an if statement on we using this custom I d variable that we created here. Andi. When Google tag manager Gooden's this, it will insert the customer I d variable into here, and we can use it just like a valuable in native JavaScript to say only one this. If there's a customer, I d there and we just hit save and thats done