Google Tag Manager in an Expo project?

What is the best approach to integrating Google Tag Manager analytics into an Expo project?

Google’s Mobile API solutions are platform specific and require Firebase Analytics via Firebase SDK.

GoogleAnalyticsBridge looks great for RN projects, but doesn’t work with Expo.

https://github.com/idehub/react-native-google-analytics-bridge

Is it possible to use the Tag Manager REST API via the js client library?

https://developers.google.com/api-client-library/javascript/start/start-js

If anyone has managed to get GTM working in Expo please help out! Thanks.

1 Like

it seems like you could very likely use the REST API and probably the JS client library though you may have to patch it a little bit so that it works under RN if there’s any web specific stuff (common examples are the way that HTTP requests are made – you’ll need to switch those to fetch if they aren’t being made that way already, and if there are references to the DOM API, ex. document.location, etc., you’d want to change or remove those.)

Requests are all abstracted by the client library, made by the gapi.client object, so I’m not sure how they are actually made under the hood. Looking at the js client code, there are references to document and window.location so I’m not sure just loading it would work.

I ended up just using standard GA with react-native-google-analytics. It works great for basic tracking, but it would be nice if there was a way to use the GA and/or Firebase native libs without detaching from Expo.

1 Like

Hey @pstahleybg,

Looks like we have a feature request for this. Make sure you go upvote it so we know it’s something you want as well. Support for firebase analytics | Voters | Expo

Cheers,

Adam

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.