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

Use engagementRate and display it as a percentage. #6690

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"maximums": [
{
"dimensionValues": [ { "value": "RESERVED_MAX" } ],
"metricValues": [ { "value": "89" }, { "value": "62" } ]
"metricValues": [
{ "value": "89" },
{ "value": "0.6174966930411756" }
]
}
],
"metadata": {
Expand All @@ -13,41 +16,62 @@
},
"metricHeaders": [
{ "name": "sessions", "type": "TYPE_INTEGER" },
{ "name": "newUsers", "type": "TYPE_INTEGER" }
{ "name": "engagementRate", "type": "TYPE_FLOAT" }
],
"minimums": [
{
"dimensionValues": [ { "value": "RESERVED_MIN" } ],
"metricValues": [ { "value": "55" }, { "value": "14" } ]
"metricValues": [
{ "value": "55" },
{ "value": "0.14262126828543842" }
]
}
],
"rowCount": 5,
"rows": [
{
"dimensionValues": [ { "value": "20201229" } ],
"metricValues": [ { "value": "55" }, { "value": "14" } ]
"metricValues": [
{ "value": "55" },
{ "value": "0.14262126828543842" }
]
},
{
"dimensionValues": [ { "value": "20201230" } ],
"metricValues": [ { "value": "3" }, { "value": "13" } ]
"metricValues": [
{ "value": "3" },
{ "value": "0.13729542959481478" }
]
},
{
"dimensionValues": [ { "value": "20201231" } ],
"metricValues": [ { "value": "17" }, { "value": "39" } ]
"metricValues": [
{ "value": "17" },
{ "value": "0.38743476173840463" }
]
},
{
"dimensionValues": [ { "value": "20210101" } ],
"metricValues": [ { "value": "10" }, { "value": "73" } ]
"metricValues": [
{ "value": "10" },
{ "value": "0.7306178859435022" }
]
},
{
"dimensionValues": [ { "value": "20210102" } ],
"metricValues": [ { "value": "89" }, { "value": "62" } ]
"metricValues": [
{ "value": "89" },
{ "value": "0.6174966930411756" }
]
}
],
"totals": [
{
"dimensionValues": [ { "value": "RESERVED_TOTAL" } ],
"metricValues": [ { "value": "89" }, { "value": "62" } ]
"metricValues": [
{ "value": "89" },
{ "value": "0.6174966930411756" }
]
}
]
}
13 changes: 13 additions & 0 deletions assets/js/modules/analytics-4/utils/data-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const ANALYTICS_4_METRIC_TYPES = {
conversions: 'TYPE_INTEGER',
screenPageViews: 'TYPE_INTEGER',
engagedSessions: 'TYPE_INTEGER',
engagementRate: 'TYPE_FLOAT',
averageSessionDuration: 'TYPE_SECONDS',
};

Expand Down Expand Up @@ -118,6 +119,18 @@ function generateMetricValues( validMetrics ) {
.toString(),
} );
break;
case 'TYPE_FLOAT':
values.push( {
value: faker.datatype
.float( {
min: 0,
max: 1,
// The GA4 API returns 17 decimal places, so specify that here, although it seems like Faker is only returning up to 16.
precision: 0.00000000000000001,
} )
.toString(),
} );
break;
case 'TYPE_SECONDS':
values.push( {
value: faker.datatype
Expand Down
2 changes: 1 addition & 1 deletion assets/js/modules/analytics-4/utils/data-mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe( 'getAnalytics4MockResponse', () => {
name: 'sessions',
},
{
name: 'newUsers',
name: 'engagementRate',
},
],
dimensions: [ 'date' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Ready.args = {
};
Ready.scenario = {
label: 'Modules/Analytics/Widgets/DashboardOverallPageMetricsWidgetGA4/Ready',
delay: 250,
delay: 500,
};

export const Loading = Template.bind( {} );
Expand Down Expand Up @@ -200,7 +200,7 @@ ZeroData.args = {
};
ZeroData.scenario = {
label: 'Modules/Analytics/Widgets/DashboardOverallPageMetricsWidgetGA4/ZeroData',
delay: 250,
delay: 500,
};

export const Error = Template.bind( {} );
Expand Down Expand Up @@ -244,7 +244,7 @@ LoadedEntityURL.args = {
};
LoadedEntityURL.scenario = {
label: 'Modules/Analytics/Widgets/DashboardOverallPageMetricsWidgetGA4/LoadedEntityURL',
delay: 250,
delay: 500,
};

export const LoadingEntityURL = Template.bind( {} );
Expand Down Expand Up @@ -358,7 +358,7 @@ ZeroDataEntityURL.args = {
};
ZeroDataEntityURL.scenario = {
label: 'Modules/Analytics/Widgets/DashboardOverallPageMetricsWidgetGA4/ZeroDataEntityURL',
delay: 250,
delay: 500,
};

export const ErrorEntityURL = Template.bind( {} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function ModulePopularPagesWidgetGA4( props ) {
name: 'sessions',
},
{
name: 'engagedSessions',
name: 'engagementRate',
},
{
name: 'averageSessionDuration',
Expand Down Expand Up @@ -188,7 +188,7 @@ function ModulePopularPagesWidgetGA4( props ) {
hideOnMobile: true,
field: 'metricValues.2.value',
Component: ( { fieldValue } ) => (
<span>{ numFmt( fieldValue, { style: 'decimal' } ) }</span>
<span>{ numFmt( fieldValue, '%' ) }</span>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const reportOptions = [
name: 'sessions',
},
{
name: 'engagedSessions',
name: 'engagementRate',
},
{
name: 'averageSessionDuration',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.