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

Adding Google Tag Manager Functionality #76

Open
wants to merge 3 commits into
base: improve-build
Choose a base branch
from

Conversation

warrenhbrown
Copy link

This pull request adds support for Google Tag Manager (GTM) so a Web Portal instance may report search and click events to Google Analytics. GTM may be configured with the "gtmContainerId: Google Tag Manager container ID" in settings.json.

We wish to share this functionality with the global community of Web

Copy link
Contributor

@grantfitzsimmons grantfitzsimmons left a comment

Choose a reason for hiding this comment

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

Looks great @warrenhbrown! On your site I see that the Google Tag Manager script is loaded into the <head>. Looks great!

@specify/dev-testing We need to edit the settings.json file and add a line that sets gtmContainerId to a Google Tag Manager container ID (it accepts a string). We need to confirm that it does nothing when not configured. If we insert a container ID, it should load the GTM script into the <head>.

@youngjames
Copy link

Hi all, thanks for considering these updates. I just wanted to add that the search-related event tracking changes are limited to Advanced search, as that is the default preference for our institution. We can add that same functionality to the Express search to capture the queries if you think there's value there too. Just let know. Thanks again.

Copy link

@melton-jason melton-jason left a comment

Choose a reason for hiding this comment

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

To my understanding, it looks like anyone wishing to utilize the dataLayer needs to define these specific events or variables pushed to the dataLayer via the Google Tag Manager.

(See https://support.google.com/tagmanager/answer/6164391?hl=en and https://developers.google.com/tag-platform/tag-manager/datalayer)

If there are any further steps required for setting this up completely which are outside of the normal WebPortal configuration, could you please expand on them so documentation regarding this new functionality can be properly written?

Comment on lines +163 to +166
window.dataLayer.push({
'event': 'search_query',
'searchQuery': filterStr
});

Choose a reason for hiding this comment

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

See comment above

Comment on lines +382 to +386
window.dataLayer.push({
'event': 'image_detail',
'attachmentId': imgRecord.data.AttachmentID,
'attachmentTitle': imgRecord.data.Title
});

Choose a reason for hiding this comment

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

See comment above

Comment on lines +532 to +535
window.dataLayer.push({
'event': 'record_detail',
'catalogNumber': record.data.catalogNumber
});

Choose a reason for hiding this comment

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

See comment above

@youngjames
Copy link

Correct. Automatically collected events and enhanced event measurement are far simpler implementations and would have been our preference. Unfortunately, these only work with traditional websites with full page reloads or single page applications that reflect state changes in the URL as a visitor interacts with them. This doesn't appear to be the case with this version of the Web Portal. So we went the custom event route, which is admittedly tailored to our needs here and can add a significant amount of complexity in terms of wiring up GTM, GA, and all the custom reporting interfaces to capture these.

Now even without these events, it is still possible to collect valuable insights beyond what is currently available — metrics such as session lengths, unique users, tech platforms, etc. So perhaps it makes more sense to remove these custom events from the codebase, while leaving the gtm.js script intact for the wider community. Then each institution can decide how exactly they'd like to configure custom events, if at all.

I would refer to Google's documentation for configuring GTM/GA wiring:

And for custom events, this is a very detailed guide that I found to be helpful:

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

5 participants