-
Notifications
You must be signed in to change notification settings - Fork 110
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
Bring Google Tag Manager custom HTML tags into cfgov-refresh #3919
Conversation
Note that edits to the actual scripts in |
07228c8
to
75971f4
Compare
75971f4
to
7a9792b
Compare
@@ -134,6 +134,14 @@ | |||
If you come across a script that makes a convincing case to be included in | |||
the head, then file an issue or PR to discuss including it. | |||
#} | |||
{% block javascript_loader %} |
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.
We should just recombine base-common.html with base.html. Most of the components in base.html can be overridden.
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.
Yes! Though let's give that its own PR.
This is really good; one of my favorite PRs. How does this affect apps which aren't in cfgov-refresh? |
Settings for webpack JavaScript bundling system. | ||
========================================================================== */ | ||
|
||
const BROWSER_LIST = require( '../../../../config/browser-list-config' ); |
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.
Use import statements here.
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.
As discussed in chat, webpack config is not run through babel so imports aren't allowed yet.
That's a good question. So what about this:
I'm not sure if we'd run into cross-origin issues there though? |
This is great! As a note, I think the main apps with custom analytics outside |
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.
An enthusiastic 👍 for moving these from GTM's dashboard to source control.
It looks like a lot of these reference jQuery. In talking with @anselmbradford these are OaH scripts, which still relies on jQuery.
I'm going to merge this and then test in GTM next deploy and address options for #3919 (comment) |
Google Tag Manager (GTM) introduces JS code to the site without code review and tests.
GTM also includes youtube code that may be the source of [ghe]/CFGOV/platform/issues/166.
This PR brings the existing code from GTM to this repo so that we can improve its quality and test coverage. This will run the scripts through webpack and make them available on the site at the static/apps/analytics-gtm/ URL, which will allow GTM to lazy load the scripts by utilizing the global
jsl()
function we already use to load other scripts.Additions
Changes
javascript_loader
jinja block to the head above the analytics code imports.Testing
unprocessed/apps/analytics-gtm/bah-check-rates-listeners.js
to addconsole.log( 'OAHRCAnalytics loaded!' );
on line 2.gulp build
.To line 150 of
base-common.html
5. Verify you see
OAHRCAnalytics loaded!
in the dev console when loading a page. Note: there will be an error too, unless you're viewing on the appropriate OAH page. This doesn't matter though, we just want to know that it loads.Notes
jsl(['/static/apps/analytics-gtm/js/[script to load].js']);
, where[script to load]
is the custom HTML tag to load.