-
Notifications
You must be signed in to change notification settings - Fork 85
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
Ga4/prod #173
Ga4/prod #173
Conversation
integrations/GA4/browser.js
Outdated
} | ||
/* utility functions --- Ends here --- */ | ||
|
||
isReservedName(eventName) { |
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.
add the helper methods to GA4/utils ?
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.
Done
integrations/GA4/browser.js
Outdated
window.gtag("event", event, props); | ||
} | ||
|
||
getDestinationEvent(event) { |
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.
this too to utils
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.
Done
integrations/GA4/browser.js
Outdated
return eventName.find((p) => p.src.includes(event.toLowerCase())); | ||
} | ||
|
||
getDestinationEventProperties(props, destParameter) { |
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.
same as above
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 method doc like what is the input and output format with an example
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.
better to use a library that does this? can you check once like get-value we use for transformer?
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.
done
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.
better to use a library that does this? can you check once like get-value we use for transformer?
There is a library : " loadash " using that we can do, but loading some external library means loading extra js, isn't if we use our own implementation where we can modify code as required. which means we can move above function to global and make more generic. One of the way I can think is going through loadash code and provide same implementation in our utils.
What do you say, should I use external library or implement on our own .....
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 won't be loading a js but yes our total JS SDK size will increase. We can leave it
Can you add the examples for the input and output like
/*
props: {key: val, key2:val2}
destParameter: {..}
output: {...}
*/
getDestinationEventProperties(props, destParameter) {...}
integrations/GA4/browser.js
Outdated
return destinationProperties; | ||
} | ||
|
||
getDestinationItemProperties(products, item) { |
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.
same as above
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.
done
integrations/integration_cname.js
Outdated
"Google Analytics 4": "GA4", | ||
GoogleAnalytics4: "GA4", | ||
GA4: "GA4", | ||
>>>>>>> 23bdbcd... GA4 sdk implementation |
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.
resolve conflict
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.
done
integrations/client_server_name.js
Outdated
@@ -20,8 +20,12 @@ const clientToServerNames = { | |||
OPTIMIZELY: "Optimizely", | |||
FULLSTORY: "Fullstory", | |||
TVSQUUARED: "TVSquared", | |||
<<<<<<< HEAD |
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.
resolve conflict
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.
done
integrations/GA4/browser.js
Outdated
window.gtag( | ||
"event", | ||
"page_view", | ||
(rudderElement.message.context && rudderElement.message.context.page) || |
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.
https://support.google.com/analytics/answer/9234069
let's try to map some of our params to the params mentioned in this link,
For ex: page_view ==>
- page_location
- page_referrer
- page_title
(So that we don't blow up number of unique params supported by GA..there is a limit there I think of unique params https://developers.google.com/analytics/devguides/collection/ga4/tag-guide#how_do_events_and_parameters_work_with_google_analytics_4_properties)
For extra params let's take a boolean input from config like send extra_params for page view and then send them. Also use rudderElement.message.properties instead of rudderElement.message.context.page
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 check if GA4 allows sending campaign info present under rudderElement.message.context.campaign
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.
Added function to support GA4 params and added config to decide if need to send extra params
identify(rudderElement) { | ||
if (this.sendUserId && rudderElement.message.userId) { | ||
const userId = this.analytics.userId || this.analytics.anonymousId; | ||
window.gtag("config", this.measurementId, { |
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.
this works even if identify is not the first call?
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, user is identified even if no identify call is made. As soon as ga scripts load he gets identified in google analytics.
integrations/GA4/browser.js
Outdated
throw Error("Cannot call un-named/reserved named track event"); | ||
} | ||
|
||
const obj = this.getDestinationEvent(event); |
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.
better name like destEventName
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.
done
integrations/GA4/browser.js
Outdated
/* utility functions --- Ends here --- */ | ||
|
||
isReservedName(eventName) { | ||
const reservedName = [ |
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.
reservedEventNames
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.
done
@@ -0,0 +1,83 @@ | |||
const eventName = [ |
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.
eventNamesConfigArray
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.
done
// -------- | ||
]; | ||
|
||
const eventParameter = [ |
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.
similar as above
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.
done
{ src: "checkout_id", dest: ["transaction_id"] }, | ||
]; | ||
|
||
const itemParameter = [ |
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.
similar as above
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.
done
use prettier and eslint in vs code. It will take the config from .prettierrc and .eslintrc present in the repo. |
integrations/index.js
Outdated
@@ -17,8 +17,12 @@ import * as Optimizely from "./Optimizely"; | |||
import * as Bugsnag from "./Bugsnag"; | |||
import * as Fullstory from "./Fullstory"; | |||
import * as TVSquared from "./TVSquared"; | |||
<<<<<<< HEAD |
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.
missed 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 fixed it
integrations/GA4/browser.js
Outdated
} | ||
|
||
page(rudderElement) { | ||
const page = |
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.
change to pageProps
get the value from message.properties. Reason: for page call to Rudder SDK ==> this is the syntax:
page(, {}, ...)
here properties can be any custom param, which is not present un message.context.page (the contextual info only contains standard params like referrer, url, title etc)
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.
done
integrations/GA4/utility.js
Outdated
); | ||
} | ||
|
||
function getDestinationEventProperties(props, destParameter) { |
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.
destParameter ==> destParameterConfig
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.
done
integrations/GA4/utility.js
Outdated
return reservedEventNames.includes(name); | ||
} | ||
|
||
function getDestinationEventName(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.
events ==> event
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.
done
integrations/GA4/browser.js
Outdated
} | ||
/* utility functions --- Ends here --- */ | ||
|
||
getDestinationItemProperties(products, item) { |
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.
forgot to remove from 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.
now removed
integrations/GA4/browser.js
Outdated
const items = []; | ||
let obj = {}; | ||
products.forEach((p) => { | ||
obj = { |
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.
better name than obj
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.
obj -> eventMappingObj
{ src: "affiliation", dest: ["affiliation"] }, | ||
{ src: "shipping", dest: ["shipping"] }, | ||
{ src: "tax", dest: ["tax"] }, | ||
{ src: "affiliation", dest: ["affiliation"] }, |
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.
remove duplicate
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.
done
add a way to check and abort if item_id/item_name, promotion_id/promotion_name, search_term are not present in the final destination payload. |
|
|
||
const eventParametersConfigArray = [ | ||
{ src: "query", dest: ["search_term"] }, | ||
{ src: "list_id", dest: ["item_list_id", "items.item_list_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.
instead of array, use a flag like storeAlsoInItems: true/false
that will make the parsing simpler?
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.
okkk looking into it
], | ||
hasItem: true, | ||
hasMultiplePayload: true, |
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.
do we need this?
can we do this:
{
src: ["payment info entered"],
dest: "add_payment_info",
hasItem: false,
onlyIncludeParams: includeParams.PaymentInfo,
},
{
src: ["payment info entered"],
dest: "add_shipping_info",
hasItem: false,
onlyIncludeParams: includeParams.ShippingInfo,
},
and filter multiple events by same src name?
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 can do this as well
…dMultiplepayload flag. Also includeList instead of onlyparams for Payment Info Entered.
Description of the change
Type of change
Related issues
Checklists
Development
Code review
This change is