-
Notifications
You must be signed in to change notification settings - Fork 139
Google Analytics 4 #570
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
Google Analytics 4 #570
Conversation
| for (var i = 0; i < measurementIds.length; i++) { | ||
| config.push(['config', measurementIds[i]]); | ||
| } | ||
|
|
||
| // Disable Page View Measurement | ||
| // https://developers.google.com/analytics/devguides/collection/ga4/disable-page-view | ||
| if (opts.disablePageViewMeasurement) { | ||
| for (var i = 0; i < measurementIds.length; i++) { | ||
| config.push([ | ||
| 'config', | ||
| measurementIds[i], | ||
| { | ||
| send_page_view: false | ||
| } | ||
| ]); | ||
| } | ||
| } |
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 looks like we add the GA properties then if they have another setting enabled ie disablePageViewMeasurement push the same properties to the config with with send_page_view: false Curious if this causes any dupes? Looks like config is just an array. I.e. should we have
config.push([
'config',
measurementIds[i],
{ allParamtersHere}
])
It could need to be separate for a reason I am not aware, just checking 😄
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 if this would cause dupes. I think it would be cleaner to push the properties once, so I can make that change.
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.
Thank you so much for calling this out! Seems when we call config multiple times it may overwrite others 🤔.
| var props = page.properties(); | ||
| var name = page.fullName(); | ||
|
|
||
| // var language = ; |
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 if we have or are working on a plan for language? I see in the SDD that Segment doesn't have it specced for a.js events.
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 don't think it is part of the Segment spec which is why I left it commented. It is mapped in the SDD but I don't think it's crucial for the pilot version. I can remove for now and re-add if there are asks for it!
| cookie_expires: opts.cookieExpiration, | ||
| }; | ||
|
|
||
| var sets = [ |
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 this be an array of objects? A little bit confused by the different format of Cookie Flags and the rest of them. Could be missing something
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.
gtag.js has a set command and it's really confusing. Sometimes it accepts a single object argument (L1) and sometimes it accepts multiple arguments (L2):
window.gtag('set', { cookie_flags: opts.cookieFlags })
window.gtag('set', 'allow_google_signals', !opts.disableAllAdvertisingFeatures)
The sets var we have is an array of arrays to represent a list of set commands and the arguments to pass.
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.
Gotcha makes sense. Thanks for clarifying
| * can be appended as part of the user_properties object instead of being configured by | ||
| * an explicit command. | ||
| * https://developers.google.com/analytics/devguides/collection/ga4/cookies-user-id#set_user_id | ||
| */ |
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.
Small nit: should we move the comment to L to be aligned
|
@brennan @briemcnally - Jen and I went through the test plans on Friday and all functionality is working as expected. There may be changes to the setting names today, but not a drastic change in behavior. Thanks for the reviews so far! |
briemcnally
left a comment
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.
LGTM! Nice work @gpsamson
| return; | ||
| } | ||
|
|
||
| // Track categorized pages setting needed 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.
Have we been able to look into this? :)
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 ran it by Jen but no response yet. I think we can leave it out for now and add it if customers request it. What do you think?
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.
Jen recommended we omit it until this functionality is requested.
| var mappings = this.options.customEventsAndParameters; | ||
|
|
||
| for (var i = 0; i < mappings.length; i++) { | ||
| var mapping = mappings[i]; // Type check for object? |
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.
Wondering per the comment if we should put a type check for object here?
| continue; | ||
| } | ||
|
|
||
| var parameterMappings = mapping.parameters || []; // Type check for array? |
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.
Also curious about this comment re: a type check for array. Is that something we should add?
| // eg; [{ key: 'properties.genre', value: 'primary_genre }] | ||
| // | ||
| for (var j = 0; j < parameterMappings.length; j++) { | ||
| var map = parameterMappings[j] || {}; // Type check for object? |
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.
Another type-check comment here as well.
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.
@gpsamson Not a big deal, but looks like we still have a type-check comment 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.
Oops, thx! I will remove it prior to merging.
| parameters[param] = value; | ||
| } | ||
|
|
||
| window.gtag('event', googleEvent, reject(parameters)); |
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.
Wondering if we need reject here given line 292 above - if map. value is falsy, then we don't add the key:value pair to the parameters map in the first place.
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.
Good call - it's pretty redundant!
|
Thanks for the review @brennan @briemcnally :tribe: I downgraded the version to |
|
Is there any process or timeline for this to be published to npm? |
What does this PR do?
This pull request introduces a new Google Analytics 4 to service the new GA4 property type which varies greatly from Universal property types. It includes functionality up to P2 in the work breakdown.
The complete spec can be found in the GA4 A.js Destination SDD.
Are there breaking changes in this PR?
No
Testing
Detailed testing can be found here: https://paper.dropbox.com/doc/GA4-A.js-Test-Plan--BHKEytO0krCgb7Rq0ETLY6TBAg-hIeXHKehkOvlhqONgOGdV
Does this require a new integration setting? If so, please explain how the new setting works
A completely new definition can be found in Partner Portal for
google-analytics-4Links to helpful docs and other external resources
https://developers.google.com/analytics/devguides/collection/ga4/tag-guide is heavily referenced throughout the code.