Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTM Samples #1218

Closed
ctsstc opened this issue Jun 18, 2018 · 10 comments
Closed

GTM Samples #1218

ctsstc opened this issue Jun 18, 2018 · 10 comments
Assignees
Labels
help wanted We'd love to have community involvement on this issue. type: question Request for information or clarification. Not an issue.

Comments

@ctsstc
Copy link

ctsstc commented Jun 18, 2018

Does this library support Google Tag Manager?

I haven't found anything about it although GTM seems to link to this repo and its examples folder but lacks any examples for such.

In-links

Searching Issues

I found these but they seem to be closed out

@JustinBeckwith JustinBeckwith added the triage me I really want to be triaged. label Jun 18, 2018
@JustinBeckwith
Copy link
Contributor

Good news! We do support tagmanager v1 and v2:
https://github.com/google/google-api-nodejs-client/tree/master/src/apis/tagmanager

The README there is not correct quite yet, so please ignore that. We don't have a sample, but that's something we can add to the list!

@JustinBeckwith JustinBeckwith added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Jun 19, 2018
@ctsstc
Copy link
Author

ctsstc commented Jun 20, 2018

Thanks for pointing me in the right direction @JustinBeckwith

I can't seem to get the auth going, is there something I'm doing wrong or missing below?
I tried passing auth through the Tagmanager as well as the Accounts.get

I've created an API key through the google console as the other guides state.
It throws: Error: Login Required code: 401

Edit: I'm starting to realize it may have been created under the incorrect organization, so I'll give that a try later when I'm back at a computer.

Edit2: I ended up using a service account and JWT, I had to add the provisioned service account email to the GTM container and give it proper access.

import config from './config/config';
import { tagmanager_v2 as gtm } from 'googleapis';
const tagManager = new gtm.Tagmanager({ auth: config.gtmApiKey });
const gtmAccounts = new gtm.Resource$Accounts(tagManager);

gtmAccounts
  .get({ auth: config.gtmApiKey, path: 'accounts/91730' })
  .then((x: any) => console.log('SUCCESS!', x))
  .catch((x: any) => console.log('KABOOM!', x));

@JustinBeckwith JustinBeckwith added the help wanted We'd love to have community involvement on this issue. label Nov 16, 2018
@jwerre
Copy link

jwerre commented Aug 28, 2019

Is the example still in the works? Documentation or and example would be very helpful.

@bcoe
Copy link
Contributor

bcoe commented Sep 5, 2019

@ctsstc I gather that you go things working? would happily accept a patch with updated docs or samples. @jwerre can you use the code @ctsstc pasted as a starting point?

@jwerre
Copy link

jwerre commented Sep 5, 2019

@bcoe I did not. I plan on getting to this next week though. I'll post an example unless you beat me to it.

@headwinds
Copy link

@jwerre

I'm also interested in sample code but first what I'd like to accomplish...

In today's age of importing libraries, is it now possible to use GTM without having to add a script tag snippet into your header?

I noticed that when you add the gtm.js as script snippet - it downloads about 200KB of JS including itself and some dynamically loaded Facebook tracking code (fbevents.js) - even with server-side compression.

I'm hoping that there is alternative API solution where I could get around this ancient attach script approach - eliminate the 200KB download - and interact with an API instead.

@jakiestfu
Copy link

Is there no progress or update on this?

@JustinBeckwith
Copy link
Contributor

Nope. We have no immediate plans here beyond the examples generated in the jsdoc comments. Happy to accept PRs!

@ctsstc
Copy link
Author

ctsstc commented Jun 2, 2020

@bcoe I think I ended up abandoning this, and we just rolled our own library that we inject through GTM since we have a centralized GTM already on hundreds of sites.

It seems that a few of our painpains have been addressed through the standard UI for GTM, but it's still nice to have greater control, and there are still a few things we prefer to have in our own codebase. It would be really nice though to be able to just utilize GTM's libraries rather than reinvent the wheel in some places.

Revisiting this now, it may be possible that we would build this out differently. It can get segmented between GTM and our codebase. It's also a pain writing in old JS so being able to write modern JS and transpile it for targeted browsers is nice. I would love to think GTM could/would do on-the-fly modules/components, ut I doubt they do, especially as you mention the large overhead for it. We will have to continue bootstrapping earliest in the head of the document so that we can beat other libraries to hooks -- I have seen times where other libs will prevent the propagation on events so GTM never sees it.

@fhinkel
Copy link
Contributor

fhinkel commented Dec 7, 2020

Greetings, we're closing this. Looks like the issue got resolved. Please let us know if the issue needs to be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We'd love to have community involvement on this issue. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

7 participants