Skip to content

Commit

Permalink
Merge commit '9abdb9aa12e7f0aa383ef36a01d090f51e48e082' into experien…
Browse files Browse the repository at this point in the history
…ce-decisioning
  • Loading branch information
ramboz committed Oct 3, 2023
2 parents 377efee + 9abdb9a commit 7f751a0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
24 changes: 12 additions & 12 deletions plugins/experience-decisioning/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# Franklin Experience Decisioning
# AEM Experience Decisioning

The Franklin Experience Decisioning plugin helps you quickly set up experimentation and segmentation on your Franklin project.
The AEM Experience Decisioning plugin helps you quickly set up experimentation and segmentation on your AEM project.
It is currently available to customers in collaboration with AEM Engineering via co-innovation VIP Projects.
To implement experimentation or personalization use-cases, please reach out to the AEM Engineering team in the Slack channel dedicated to your project.

## Features

The Franklin Experience Decisioning plugin supports:
The AEM Experience Decisioning plugin supports:
- :busts_in_silhouette: serving different content variations to different audiences, including custom audience definitions for your project that can be either resolved directly in-browser or against a trusted backend API.
- :money_with_wings: serving different content variations based on marketing campaigns you are running, so that you can easily track email and/or social campaigns
- :chart_with_upwards_trend: running A/B test experiments on a set of variants to measure and improve the conversion on your site. This works particularly with our :chart: [RUM conversion tracking plugin](https://github.com/adobe/franklin-rum-conversion).
- :rocket: easy simulation of each experience and basic reporting leveraging in-page overlays

## Installation

Add the plugin to your Franklin project by running:
Add the plugin to your AEM project by running:
```sh
git subtree add --squash --prefix plugins/experience-decisioning git@github.com:adobe/franklin-experience-decisioning.git main
git subtree add --squash --prefix plugins/experience-decisioning git@github.com:adobe/aem-experience-decisioning.git main
```

If you later want to pull the latest changes and update your local copy of the plugin
```sh
git subtree pull --squash --prefix plugins/experience-decisioning git@github.com:adobe/franklin-experience-decisioning.git main
git subtree pull --squash --prefix plugins/experience-decisioning git@github.com:adobe/aem-experience-decisioning.git main
```

If you prefer using `https` links you'd replace `git@github.com:adobe/franklin-experience-decisioning.git` in the above commands by `https://github.com/adobe/franklin-experience-decisioning.git`.
If you prefer using `https` links you'd replace `git@github.com:adobe/aem-experience-decisioning.git` in the above commands by `https://github.com/adobe/aem-experience-decisioning.git`.

## Project instrumentation

To properly connect and configure the plugin for your project, you'll need to edit your `scripts.js` in your Franklin project and add the following:
To properly connect and configure the plugin for your project, you'll need to edit your `scripts.js` in your AEM project and add the following:

1. at the start of the file:
```js
Expand Down Expand Up @@ -108,7 +108,7 @@ You have already seen the `audiences` option in the examples above, but here is
```js
runEager.call(pluginContext, {
/* Generic properties */
// RUM sampling rate on regular franklin pages is 1 out of 100 page views
// RUM sampling rate on regular AEM pages is 1 out of 100 page views
// but we increase this by default for audiences, campaigns and experiments
// to 1 out of 10 page views so we can collect metrics faster of the relative
// short durations of those campaigns/experiments
Expand All @@ -135,6 +135,6 @@ runEager.call(pluginContext, {
```

For detailed implementation instructions on the different features, please read the dedicated pages we have on those topics:
- [Audiences](../../wiki/Audiences)
- [Campaigns](../../wiki/Campaigns)
- [Experiments](../../wiki/Experiments)
- [Audiences](https://github.com/adobe/aem-experience-decisioning/wiki/Audiences)
- [Campaigns](https://github.com/adobe/aem-experience-decisioning/wiki/Campaigns)
- [Experiments](https://github.com/adobe/aem-experience-decisioning/wiki/Experiments)
4 changes: 2 additions & 2 deletions plugins/experience-decisioning/package-lock.json

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

10 changes: 5 additions & 5 deletions plugins/experience-decisioning/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@adobe/franklin-experience-decisioning",
"name": "@adobe/aem-experience-decisioning",
"version": "1.0.0",
"main": "src/index.js",
"scripts": {
Expand All @@ -9,12 +9,12 @@
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/adobe/franklin-experience-decisioning.git"
"url": "git+ssh://git@github.com/adobe/aem-experience-decisioning.git"
},
"author": "Adobe Inc.",
"license": "Apache-2.0",
"keywords": [
"franklin",
"aem",
"experimentation",
"experience",
"decisioning",
Expand All @@ -23,9 +23,9 @@
"audiences"
],
"bugs": {
"url": "https://github.com/adobe/franklin-experience-decisioning/issues"
"url": "https://github.com/adobe/aem-experience-decisioning/issues"
},
"homepage": "https://github.com/adobe/franklin-experience-decisioning#readme",
"homepage": "https://github.com/adobe/aem-experience-decisioning#readme",
"devDependencies": {
"eslint": "8.48.0",
"eslint-config-airbnb-base": "15.0.0",
Expand Down
20 changes: 10 additions & 10 deletions plugins/experience-decisioning/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export async function runExperiment(customOptions = {}) {

export async function runCampaign(customOptions) {
if (isBot()) {
return null;
return false;
}

const options = { ...DEFAULT_OPTIONS, ...customOptions };
Expand All @@ -451,7 +451,7 @@ export async function runCampaign(customOptions) {
: null)
|| (usp.has('utm_campaign') ? this.toClassName(usp.get('utm_campaign')) : null);
if (!campaign) {
return null;
return false;
}

const audiences = this.getMetadata(`${options.audiencesMetaTagPrefix}-audience`)
Expand All @@ -463,12 +463,12 @@ export async function runCampaign(customOptions) {

const allowedCampaigns = this.getAllMetadata(options.campaignsMetaTagPrefix);
if (!Object.keys(allowedCampaigns).includes(campaign)) {
return null;
return false;
}

const urlString = allowedCampaigns[campaign];
if (!urlString) {
return null;
return false;
}

try {
Expand All @@ -487,27 +487,27 @@ export async function runCampaign(customOptions) {
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
return null;
return false;
}
}

export async function serveAudience(customOptions) {
if (isBot()) {
return null;
return false;
}

const pluginOptions = { ...DEFAULT_OPTIONS, ...customOptions };
const configuredAudiences = this.getAllMetadata(pluginOptions.audiencesMetaTagPrefix);
if (!Object.keys(configuredAudiences).length) {
return null;
return false;
}

const audiences = await getResolvedAudiences(
Object.keys(configuredAudiences),
pluginOptions,
);
if (!audiences || !audiences.length) {
return null;
return false;
}

const usp = new URLSearchParams(window.location.search);
Expand All @@ -517,7 +517,7 @@ export async function serveAudience(customOptions) {

const urlString = configuredAudiences[forcedAudience || audiences[0]];
if (!urlString) {
return null;
return false;
}

try {
Expand All @@ -536,7 +536,7 @@ export async function serveAudience(customOptions) {
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
return null;
return false;
}
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/experience-decisioning/src/preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

.hlx-preview-overlay {
z-index: 99;
z-index: 999;
position: fixed;
bottom: 32px;
right: 32px;
Expand Down Expand Up @@ -96,6 +96,7 @@
display: inline-block;
border-radius: 20px;
text-decoration: none;
word-break: normal;
}

.hlx-popup-header {
Expand Down
8 changes: 4 additions & 4 deletions plugins/experience-decisioning/src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function populatePerformanceMetrics(div, config, {
}

/**
* Create Badge if a Page is enlisted in a Helix Experiment
* Create Badge if a Page is enlisted in a AEM Experiment
* @return {Object} returns a badge or empty string
*/
async function decorateExperimentPill(overlay, options) {
Expand Down Expand Up @@ -325,7 +325,7 @@ function createCampaign(campaign, isSelected, options) {
}

/**
* Create Badge if a Page is enlisted in a Franklin Campign
* Create Badge if a Page is enlisted in a AEM Campaign
* @return {Object} returns a badge or empty string
*/
async function decorateCampaignPill(overlay, options) {
Expand Down Expand Up @@ -384,7 +384,7 @@ function createAudience(audience, isSelected, options) {
}

/**
* Create Badge if a Page is enlisted in a Franklin Campign
* Create Badge if a Page is enlisted in a AEM Audiences
* @return {Object} returns a badge or empty string
*/
async function decorateAudiencesPill(overlay, options) {
Expand Down Expand Up @@ -422,7 +422,7 @@ async function decorateAudiencesPill(overlay, options) {
*/
export default async function decoratePreviewMode(options) {
try {
this.loadCSS('/plugins/experience-decisioning/src/preview.css');
this.loadCSS(`${window.hlx.codeBasePath}/plugins/experience-decisioning/src/preview.css`);
const overlay = getOverlay(options);
await decorateAudiencesPill.call(this, overlay, options);
await decorateCampaignPill.call(this, overlay, options);
Expand Down

0 comments on commit 7f751a0

Please sign in to comment.