From the course: Learning Google Tag Manager

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Dynamic variables

Dynamic variables - Google Tag Manager Tutorial

From the course: Learning Google Tag Manager

Start my 1-month free trial

Dynamic variables

- [Instructor] Okay, now let's put all this together. In the introductions chapter, we discussed an example of a dynamic variable that was populated by our shopping cart which held the current shopping cart total. So let's go ahead and create that variable. We're going to head on down here to variables and we're going to select a new user defined variable. We're going to do a custom JavaScript variable. So we come down here to JavaScript variable. And now this is where it's going to be a little bit different for everyone. In my particular cart, cart total is stored in a global JavaScript variable called cart total. So I'm going to put that variable name in here. Kind of like that. Now yours may be a little bit different. You can also get this from a cookie. You can get it from the URL. You can get it from a data layer variable, which we'll talk about a little bit later. You can even just scrape this text right off the…

Contents