-
Notifications
You must be signed in to change notification settings - Fork 64
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
feat: Add support for Google Tag Manager #631
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @xitij2000! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
This change adds support for Google Tag Manager along with some common options for Google Tag Manager.
8d1a426
to
64f4e85
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #631 +/- ##
==========================================
+ Coverage 83.50% 83.90% +0.40%
==========================================
Files 40 41 +1
Lines 1073 1100 +27
Branches 197 204 +7
==========================================
+ Hits 896 923 +27
Misses 165 165
Partials 12 12 ☔ View full report in Codecov by Sentry. |
Hi @openedx/fed-bom @openedx/2u-fed-bom! (not sure which group to use). This is ready for review. Thanks! |
Hi @openedx/2u-fed-bom! Just following up on this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could please provide some more context of this change and its impact
constructor({ config }) { | ||
this.gtmId = config.GOOGLE_TAG_MANAGER_ID; | ||
this.gtmArgs = ''; | ||
if (config.GOOGLE_TAG_MANAGER_AUTH) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add respective config in the env as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where else it needs to be added. It's an optional feature, so it should not be there in the default config.
I've updated the PR description, do tell if there is need for additional context or info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This started as a conversation in #wg-frontend. Transcribing here.)
This looks like it would be useful, so I don't want to get in the way. At the same time, I think it would make a lot of sense if we could, instead of adding explicit support for GTM in frontend-platform, make it so that people could add any such script they want without having to submit it upstream. The advantages being:
- For the user: no need to try and get it merged
- For the maintainer: no need to make sure specific providers continue to work, are compliant, etc
I'm thinking that if one could define GoogleTagManagerLoader in an array of such loaders in env.config.js
with a predefined name... say, externalScripts
? Then all we need to do here is make sure that initialize()
also (or instead) looks for external scripts that come from env.config
.
Thoughts?
const { googleTagManager } = global; | ||
|
||
// If the snippet was invoked do nothing. | ||
if (googleTagManager.invoked) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious-passerby] Could you give an example where loadScript would be called twice? I feel like it is only being called from initialize, and initialize should only be called once in an app, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zawan-ila I did not put much thought into this, I copied the basic framework for the GoogleAnalyticsLoader script so I assumed that tracking the invocation and ensuring it is loaded only once was being done in that script because it was a possibility.
I already replied there but my only issue with reading Of course, someone can just install the package and manually populate it as well, and that will likely be simpler. I can work on that approach when we have the capacity to continue this work. |
I think that's a fine idea. I figure we could support both mechanisms, though. Auto- and manual loading. |
Hi @xitij2000 - just checking in to see if this is still in progress? |
Sorry for the late reply. I'm hoping to work on this in an upcoming sprint. |
This change adds support for Google Tag Manager along with some common options for Google Tag Manager.
Google Tag Manager is a tag management system that can be used for conversion tracking, analytics etc. This change will allow configuring and using GTM in addition to Google Analytics.