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

feat: high bounce rate and low ctr opportunities #384

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@adobe/spacecat-shared-data-access": "1.43.3",
"@adobe/spacecat-shared-google-client": "1.2.2",
"@adobe/spacecat-shared-http-utils": "1.6.8",
"@adobe/spacecat-shared-rum-api-client": "2.8.0",
"@adobe/spacecat-shared-rum-api-client": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-rum-api-client?0ffe830c28130f8ad8050a5c8ac0226ccd54e3b0",
"@adobe/spacecat-shared-rum-api-client-v1": "npm:@adobe/[email protected]",
"@aws-sdk/client-lambda": "3.637.0",
"@aws-sdk/credential-provider-node": "3.637.0",
Expand Down
11 changes: 8 additions & 3 deletions src/opportunities/opportunities.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import { AuditBuilder } from '../common/audit-builder.js';
import { getRUMDomainkey } from '../support/utils.js';

const DAYS = 30;
const OPPTY_QUERIES = [
Copy link
Contributor

Choose a reason for hiding this comment

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

since there can be other opportunities, which are not experimentation related, so I've kept those as experimentationHandlers, so can we still keep the word experimentation? like EXPERIMENTATION_OPPTY_QUERIES ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, more accurate name for this audit should be experimentation-opportunities because it only encompasses the experimentation opportunities. Other type opportunities such as broken backlinks or cwv etc. are covered in different audits. Consecutively, I renamed the audit

'rageclick',
'high-inorganic-high-bounce-rate',
'high-organic-low-ctr',
];

let log = console;

Expand All @@ -40,13 +45,13 @@ export async function opportunitiesHandler(auditUrl, context, site) {
interval: DAYS,
granularity: 'hourly',
};
const experimentationHandlers = ['rageclick'];
const queryResults = await rumAPIClient.queryMulti(experimentationHandlers, options);

const queryResults = await rumAPIClient.queryMulti(OPPTY_QUERIES, options);
const auditData = {
experimentationOpportunities: [],
};
for (const queryResult of Object.keys(queryResults)) {
if (experimentationHandlers.includes(queryResult)) {
if (OPPTY_QUERIES.includes(queryResult)) {
auditData.experimentationOpportunities.push(...queryResults[queryResult]);
}
}
Expand Down
23 changes: 13 additions & 10 deletions test/audits/opportunities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,20 @@ describe('Opportunities Tests', () => {
};
const auditData = await opportunitiesHandler(url, context, site);

expect(context.rumApiClient.queryMulti).calledWith(
['rageclick'],
{
domain: 'https://abc.com',
domainkey: 'abc_dummy_key',
interval: 30,
granularity: 'hourly',
},
);
const expected = Object.values(opportunitiesData).flatMap((data) => data);

expect(context.rumApiClient.queryMulti).calledWith([
'rageclick',
'high-inorganic-high-bounce-rate',
'high-organic-low-ctr',
], {
domain: 'https://abc.com',
domainkey: 'abc_dummy_key',
interval: 30,
granularity: 'hourly',
});
expect(
auditData.auditResult.experimentationOpportunities,
).to.deep.equal(opportunitiesData.rageclick);
).to.deep.equal(expected);
});
});
22 changes: 21 additions & 1 deletion test/fixtures/opportunitiesdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,25 @@
}
]
}
]
],
"high-organic-low-ctr": [{
"type": "high-organic-low-ctr",
"page": "https://abc.com/abc-adoption/account",
"screenshot": "",
"trackedPageKPIName": "Click Through Rate",
"trackedPageKPIValue": "0.14",
"pageViews": 2145,
"samples": 123,
"metrics": []
}],
"high-inorganic-high-bounce-rate": [{
"type": "high-inorganic-high-bounce-rate",
"page": "https://abc.com/abc-adoption/pricing",
"screenshot": "",
"trackedPageKPIName": "Bounce Rate",
"trackedPageKPIValue": 0.76,
"pageViews": 8839,
"samples": 89,
"metrics": []
}]
}
Loading