-
Notifications
You must be signed in to change notification settings - Fork 8
device wise metrics #683
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
device wise metrics #683
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ function aggregateFormVitalsByDevice(formVitalsCollection) { | |
formVitalsCollection.forEach((item) => { | ||
const { | ||
url, formview = {}, formengagement = {}, pageview = {}, formsubmit = {}, | ||
trafficacquisition = {}, | ||
} = item; | ||
|
||
const totals = { | ||
|
@@ -54,7 +55,13 @@ function aggregateFormVitalsByDevice(formVitalsCollection) { | |
totals.formengagement = calculateSums(formengagement, totals.formengagement); | ||
totals.pageview = calculateSums(pageview, totals.pageview); | ||
totals.formsubmit = calculateSums(formsubmit, totals.formsubmit); | ||
|
||
// Traffic Acquisition is not aggregated by device type | ||
totals.trafficacquisition = { | ||
total: trafficacquisition.total ? trafficacquisition.total : null, | ||
paid: trafficacquisition.paid ? trafficacquisition.paid : null, | ||
earned: trafficacquisition.earned ? trafficacquisition.earned : null, | ||
owned: trafficacquisition.owned ? trafficacquisition.owned : null, | ||
}; | ||
resultMap.set(url, totals); | ||
}); | ||
|
||
|
@@ -90,18 +97,53 @@ export function getHighFormViewsLowConversionMetrics(formVitalsCollection) { | |
const urls = []; | ||
resultMap.forEach((metrics, url) => { | ||
const pageViews = metrics.pageview.total; | ||
const mobilePageViews = metrics.pageview.mobile; | ||
const desktopPageViews = metrics.pageview.desktop; | ||
// Default to pageViews if formViews are not available | ||
const formViews = metrics.formview.total || pageViews; | ||
let formViews = metrics.formview.total; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check if formViews = 0 |
||
let mobileFormViews = metrics.formview.mobile; | ||
let desktopFormViews = metrics.formview.desktop; | ||
if (!formViews) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets skip the fallback now as we have improved RUM to capture formviews. |
||
formViews = pageViews; | ||
mobileFormViews = mobilePageViews; | ||
desktopFormViews = desktopPageViews; | ||
} | ||
const formEngagement = metrics.formengagement.total; | ||
const formSubmit = metrics.formsubmit.total || formEngagement; | ||
const mobileFormEngagement = metrics.formengagement.mobile; | ||
const desktopFormEngagement = metrics.formengagement.desktop; | ||
let formSubmit = metrics.formsubmit.total; | ||
let mobileFormSubmit = metrics.formsubmit.mobile; | ||
let desktopFormSubmit = metrics.formsubmit.desktop; | ||
if (!formSubmit) { | ||
formSubmit = formEngagement; | ||
mobileFormSubmit = mobileFormEngagement; | ||
desktopFormSubmit = desktopFormEngagement; | ||
} | ||
|
||
if (hasHighPageViews(pageViews) && hasLowerConversionRate(formSubmit, formViews)) { | ||
urls.push({ | ||
url, | ||
pageViews, | ||
formViews, | ||
formEngagement, | ||
formSubmit, | ||
pageViews: { | ||
total: pageViews, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest to simplify it to:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can cleanup all the existing code then |
||
mobile: mobilePageViews, | ||
desktop: desktopPageViews, | ||
}, | ||
formEngagement: { | ||
total: formEngagement, | ||
mobile: mobileFormEngagement, | ||
desktop: desktopFormEngagement, | ||
}, | ||
formViews: { | ||
total: formViews, | ||
mobile: mobileFormViews, | ||
desktop: desktopFormViews, | ||
}, | ||
formSubmit: { | ||
total: formSubmit, | ||
mobile: mobileFormSubmit, | ||
desktop: desktopFormSubmit, | ||
}, | ||
trafficacquisition: metrics.trafficacquisition, | ||
}); | ||
} | ||
}); | ||
|
@@ -182,13 +224,15 @@ export function getHighPageViewsLowFormCtrMetrics(formVitalsCollection) { | |
if (deviceData != null) { | ||
urls.push({ | ||
url: entry.url, | ||
pageViews: deviceData.pageview.total, | ||
formViews: deviceData.formview.total, | ||
formEngagement: deviceData.formengagement.total, | ||
pageViews: deviceData.pageview, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here too:
|
||
formViews: deviceData.formview, | ||
formEngagement: deviceData.formengagement, | ||
formSubmit: deviceData.formsubmit, | ||
CTA: { | ||
url: maxPageviewUrl.url, | ||
source: y.source, | ||
}, | ||
trafficacquisition: deviceData.trafficacquisition, | ||
}); | ||
} | ||
} | ||
|
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.
totals.trafficacquisition = { ...trafficacquisition }