-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
OBPIH-5218 Add gtag for google analytics #3927
Conversation
awalkowiak
commented
Mar 16, 2023
- removed old google-analytics:1.0 dependency
- added gsp layout for react (copy of main) to not overwrite the main one
- added tag lib injecting gtag tracking code
- removed old google-analytics:1.0 dependency - added gsp layout for react (copy of main) to not overwrite the main one - added tag lib injecting gtag tracking code
* */ | ||
def gtag = {attrs -> | ||
if (!getTrackingIds()) { | ||
out << "" |
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.
is there a reason we're pushing an empty string 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.
No reason, we can push nothing.
|
||
gtag('config', TRACKING_ID); | ||
</script> | ||
* */ |
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.
Not sure this comment is necessary
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.
It's not not necessary. I would maybe include a link to the google tag docs to help explain the what and why.
src/assets/grails-template.html
Outdated
@@ -1,7 +1,7 @@ | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |||
<meta name="layout" content="main" /> | |||
<meta name="layout" content="react" /> |
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 confused about this change. Why not keep content="main"
here and add the <g:gtag />
line to main.gsp
? Is there a reason we need both main.gsp
and react.gsp
?
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 suggested adding this to main.gsp
on the tech huddle, and I remember @jmiranda had some concerns regarding that since it is the main layout. If he is fine with adding gtag to the main.gsp
, then I'm fine with it either.
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.
Nah, we don't use main anywhere else as far as I know. I don't remember having any reservations about that so my apologies for the confusion.
I would be more concerned with adding react.gsp since we already have a partial template _react.gsp so it might get confusing to distinguish between the two.
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.
Ok, I'll change it back to main.gsp
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.
Apart from one question my comments are very minor, take 'em or leave 'em. The thing I'm most curious about is why we have a react.gsp and a main.gsp now that appear identical except for one line. Can the code duplication be avoided?
@@ -218,7 +218,6 @@ grails.project.dependency.resolution = { | |||
// Not critical to application (might require code changes) | |||
//build(":codenarc:0.17") | |||
//compile(":dynamic-controller:0.3") | |||
compile(":google-analytics:1.0") |
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 love it when we lose a dependency! Yay!
grails-app/views/layouts/custom.gsp
Outdated
@@ -62,7 +62,7 @@ | |||
<g:render template="/common/fullstory"/> | |||
<g:render template="/common/hotjar"/> | |||
|
|||
<ga:trackPageview/> | |||
<g:gtag /> |
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.
should we not just call it the same as before?
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.
if we do change it I'd like it to be more explicit. gtag could mean anything so something like
<g:googleAnalytics />
or
<g:googleTagManager />
or
<g:globalSiteTag />
would be much better
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.
<g:globalSiteTag /> will be most suiting
* tracking ids as list of strings | ||
* */ | ||
private getTrackingIds() { | ||
return ConfigurationHolder.config.google.gtag.trackingIds |
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.
Can you explain the multiple tracking IDs? Or provide some documentation for when this might be used?
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.
You can have multiple google analytics properties. And each has to be configured separately within the gtag tracking code as:
gtag('config', TRACKING_ID_1);
gtag('config', TRACKING_ID_2);
gtag('config', TRACKING_ID_3);
...
src/assets/grails-template.html
Outdated
@@ -1,7 +1,7 @@ | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |||
<meta name="layout" content="main" /> | |||
<meta name="layout" content="react" /> |
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.
Nah, we don't use main anywhere else as far as I know. I don't remember having any reservations about that so my apologies for the confusion.
I would be more concerned with adding react.gsp since we already have a partial template _react.gsp so it might get confusing to distinguish between the two.
|
||
gtag('config', TRACKING_ID); | ||
</script> | ||
* */ |
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.
It's not not necessary. I would maybe include a link to the google tag docs to help explain the what and why.
grails-app/views/layouts/custom.gsp
Outdated
@@ -62,7 +62,7 @@ | |||
<g:render template="/common/fullstory"/> | |||
<g:render template="/common/hotjar"/> | |||
|
|||
<ga:trackPageview/> | |||
<g:gtag /> |
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.
if we do change it I'd like it to be more explicit. gtag could mean anything so something like
<g:googleAnalytics />
or
<g:googleTagManager />
or
<g:globalSiteTag />
would be much better
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.
Looks good to me! Thanks!