I have created a GTM copy paste extension and used the Google Tag Manager API to test what it can do. With the help of various GTM API features, I was able to get invaluable insights into how I make the extension work as I wanted to. In this video, I will show you how you can utilize the documentation with the Try API feature and try what the GTM API can do
GTM API Doc: https://developers.google.com/tag-manager/api/v2/devguide
Guide to the GTM API: https://online-behavior.com/index.php/analytics/tag-manager-api
GTM API Explorer: https://developers.google.com/apis-explorer/#p/tagmanager/v2/
GTM Copy Paste Extension: https://chrome.google.com/webstore/detail/gtm-copy-paste/mhhidgiahbopjapanmbflpkcecpciffa
? Learn more from Measureschool: https://measureschool.com/products
?Looking to kick-start your data journey? Hire us: https://measureschool.com/services/
? Recommended Measure Books: https://kit.com/Measureschool/recommended-measure-books
? Gear we used to produce this video: https://kit.com/Measureschool/measureschool-youtube-gear
Hello there and welcome back to another video of measureschool.com teaching you the data-driven way of digital marketing. My name is Julian, and I’m back with another quick tip on Google Tag Manager. This time we want to talk about to Google Tag Manager API, and actually how to try it out.
Now, when I was building my GTM copy paste extension, I have utilized this website a lot to understand the Google Tag Manager API and to try out certain things and how the GTM API reacts, what I get back, and so on. So it will be an invaluable resource when you want to try to work with the Google Tag Manager API. And it’s pretty well documented. Some things are not so well documented. But who’s here to complain, we want to try this out. And we can try it out by going into the references here and see what we can actually do with the GTM API. Now I’m using the Tag Manager API version 2 and what you would need is actually just this website and a Google Tag Manager account to try this out. So we have here Google Tag Manager account we have some tags in here. Let’s say we wanted to see what tags actually in the account and want to go through the GTM API to actually see this.
Now we have different commands here that we can ask the GTM API to call on. And one of those are the tags right here. And we have different commands, we can delete a tag, we can create a tag, get list and so on. We want to list actually the tag that we have available in our account. And then this little try this API thing pops up, I can make this bigger and what we would need to put in is a parent, a string and then if we wanted to have one or the second page of them with multiple tags, then we could put this in as well. Now, what is this parent thing? Its really just the URL that you see up here so Google Tag Manager knows which account to access and get the data from. And it’s everything from this slash here before the account starts, up until to the workspace and after that, it will take care of itself because it will know that you want to get the list of the tags. So I’m going to copy this and put it into the parents string right here, you can execute it. Now it needs to have access to my Google Tag Manager account. And therefore, I need to go through the auth flow of actually logging in. And here we go, we get a 200 response, which is a good response its green. And we see the different tags and what we can actually get from the Google Tag Manager API. We get the account ID, and so on. And we see the actual tags. So he has a tag ID 2 with the name GA event click, that would be this one. And in the JSON object, we have parameters in here as well.
And then it will get all the information for me in this perfectly formatted JSON format. And I can also go ahead and copy this. So now I have this and I can create a tag. Now the question was, where do you want to create this tag? So you need to put in a parent, and you need to put in a request body. Now I already have the request body from the copied information that I had before. I want to copy this exact tag into another account. So I’m just going to go into another account here.
All right, and up here, I have this different account going to copy this and put this all in right here so it knows where to put that information. Now, all I need to do is execute. Again, go through the auth flow and get information back it’s not found. So something was wrong in my actual container or my parents right here. So let’s see. Well, the parent doesn’t actually need this tags at the end here knows that it’s a tag that it wants to upload. So that should work let’s try this out again. We get a 400 error. Now 400 errors are a bit annoying because you don’t know actually what went wrong. Something is malformed inside of your tag. And this is not well documented, I must say. But I can tell you what it is. What is the problem here? And that’s probably the firing trigger ID. Because the firing trigger ID is not found in the new account so it can’t reconnect it. But if I get rid of this, so you can just plainly edit this and execute. We now see 200 we have uploaded or created this new tag, it should now turn up in our other workspace here. And here we go. We have our event click, the trigger was not ported over as the trigger is separate from the tag itself. So if you are interested in working with the Tag Manager API, and see whether it’s actually possible and try it out yourself, utilize this documentation with the try this API feature to see how it’s actually working and how you can manipulate things through the API in your Google Tag Manager account or list certain things and so on. I heavily use this as I said with the GTM copy paste extension.
Hey, it’s me again. Thanks for checking out our quick tip video. Was that helpful? Did you understand something not quite? Then I’d love to hear from you in the comments down below. But if you liked it, then why not give us a thumbs up and subscribe to our channel right over there, because we bring you new videos just like this one every week. Now, my name is Julian til next time.