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

feat: Add support for Google Tag Manager #631

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xitij2000
Copy link

@xitij2000 xitij2000 commented Jan 4, 2024

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.

@openedx-webhooks
Copy link

openedx-webhooks commented Jan 4, 2024

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If 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 @openedx/committers-frontend. Tag them in a comment and let them know that your changes are ready for review.

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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jan 4, 2024
@xitij2000 xitij2000 changed the title feat: Add support for Google Tag Manger This change adds support for Google Tag Manager along with some common options for Google Tag Manager. feat: Add support for Google Tag Manger Jan 4, 2024
This change adds support for Google Tag Manager along with some common options for Google Tag Manager.
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.90%. Comparing base (ad936a2) to head (64f4e85).
Report is 71 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@xitij2000 xitij2000 marked this pull request as ready for review January 5, 2024 10:32
@mphilbrick211 mphilbrick211 requested a review from a team January 8, 2024 15:41
@mphilbrick211
Copy link

Hi @openedx/fed-bom @openedx/2u-fed-bom! (not sure which group to use). This is ready for review. Thanks!

@mphilbrick211 mphilbrick211 added the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Feb 21, 2024
@mphilbrick211
Copy link

Hi @openedx/2u-fed-bom! Just following up on this :)

Copy link
Contributor

@abdullahwaheed abdullahwaheed left a 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) {
Copy link
Contributor

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

Copy link
Author

@xitij2000 xitij2000 Mar 22, 2024

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.

@xitij2000
Copy link
Author

could please provide some more context of this change and its impact

I've updated the PR description, do tell if there is need for additional context or info.

Copy link
Contributor

@abdullahwaheed abdullahwaheed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arbrandes arbrandes changed the title feat: Add support for Google Tag Manger feat: Add support for Google Tag Manager May 17, 2024
Copy link
Contributor

@arbrandes arbrandes left a 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) {

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?

Copy link
Author

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.

@xitij2000
Copy link
Author

(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?

I already replied there but my only issue with reading externalScripts from env.config.js is that we can use a plugin mechanism to auto-load it instead. i.e. auto-populate that array with all packages following the pattern @openedx-plugins/frontend-platform-script-* .

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.

@arbrandes
Copy link
Contributor

auto-populate that array with all packages following the pattern @openedx-plugins/frontend-platform-script-*

I think that's a fine idea. I figure we could support both mechanisms, though. Auto- and manual loading.

@mphilbrick211
Copy link

Hi @xitij2000 - just checking in to see if this is still in progress?

@mphilbrick211 mphilbrick211 added changes requested and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Jul 17, 2024
@xitij2000
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested open-source-contribution PR author is not from Axim or 2U
Projects
Status: In Eng Review
Development

Successfully merging this pull request may close these issues.

6 participants