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

OBPIH-5218 Add gtag for google analytics #3927

Merged
merged 3 commits into from
Mar 20, 2023
Merged

Conversation

awalkowiak
Copy link
Collaborator

  • 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 << ""
Copy link
Member

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?

Copy link
Collaborator Author

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>
* */
Copy link
Member

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

Copy link
Member

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.

@@ -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" />
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

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

Copy link
Member

@mdpearson mdpearson left a 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")
Copy link
Member

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!

@@ -62,7 +62,7 @@
<g:render template="/common/fullstory"/>
<g:render template="/common/hotjar"/>

<ga:trackPageview/>
<g:gtag />
Copy link
Member

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?

Copy link
Member

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

Copy link
Collaborator Author

@awalkowiak awalkowiak Mar 17, 2023

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
Copy link
Member

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?

Copy link
Collaborator Author

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);
...

https://developers.google.com/analytics/devguides/collection/gtagjs#configure_additional_google_analytics_properties

@@ -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" />
Copy link
Member

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>
* */
Copy link
Member

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.

@@ -62,7 +62,7 @@
<g:render template="/common/fullstory"/>
<g:render template="/common/hotjar"/>

<ga:trackPageview/>
<g:gtag />
Copy link
Member

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

Copy link
Member

@mdpearson mdpearson left a 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!

@awalkowiak awalkowiak merged commit edd16a0 into release/0.8.21-hotfix1 Mar 20, 2023
@awalkowiak awalkowiak deleted the OBPIH-5218 branch March 20, 2023 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants