Skip to content

Commit 3c927d3

Browse files
authored
Merge pull request #36 from humanmade/audience-ui
Audience UI
2 parents c5a29ba + 11057a2 commit 3c927d3

27 files changed

+3013
-64
lines changed

.circleci/deploy-exclude.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010
node_modules
1111
package.json
1212
package-lock.json
13-
src
1413
webpack.config.js

.circleci/deploy.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ fi
6262

6363
rsync -av "$SRC_DIR/" "$BUILD_DIR" --exclude-from "$SRC_DIR/.circleci/deploy-exclude.txt"
6464

65-
# Swap commit placeholders
66-
SCRIPT_HASH=$(md5sum build/analytics.js | awk '{ print $1 }')
67-
find . -name '*.php' | xargs sed -i.bak 's/__SCRIPT_HASH__/'"$SCRIPT_HASH"'/g'
68-
find . -name '*.bak' -delete
69-
7065
# Add changed files
7166
git add .
7267

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "humanmade",
33
"globals": {
4-
"Altis": "readonly"
4+
"Altis": "readonly",
5+
"wp": "readonly"
56
},
67
"rules": {
78
"no-multi-str": "off",

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ Similar to `registerAttribute()` above but for metrics.
4646

4747
Allows you to define the Elasticsearch server URL directly.
4848

49+
**`ALTIS_ANALYTICS_LOG_QUERIES`**
50+
51+
Define as true to enable logging queries to the error log.
52+
4953
### Filters
5054

5155
The plugin provides a few hooks for you to control the default endpoint data and attributes recorded with events.
@@ -131,6 +135,9 @@ A user session covers every event recorded between opening the website and closi
131135
- `ModelVersion`: Browser version.
132136
- `Platform`: The device operating system.
133137
- `PlatformVersion`: The operating system version.
138+
- `Location`
139+
- `Country`: The endpoint's country if known / available.
140+
- `City`: The endpoint's city if known or available.
134141
- `User`
135142
- `UserAttributes`
136143
- Any custom attributes associated with the user if known.
@@ -224,6 +231,28 @@ The output will look something like the following:
224231

225232
You can further trim the size of the returned response using the `filter_path` query parameter. For example if we're only interested in the stats aggregation we can set `filter_path=-aggregations.sessions` to remove it from the response.
226233

234+
## Audiences
235+
236+
Audiences are user-defined categories of users, based on conditions related to their analytics data.
237+
238+
Audiences allow for the creation of conditions to narrow down event queries or endpoints but also can be used for determining effects on the client side.
239+
240+
### Mapping Event Data
241+
242+
To enable the use of any event record data in the audience editor it needs to be mapped to a human readable label using the `Altis\Analytics\Audiences\register_field()` function:
243+
244+
```php
245+
use function Altis\Analytics\Audiences\register_field;
246+
247+
add_action( 'init', function () {
248+
register_field( 'endpoint.Location.City', __( 'City' ) );
249+
} );
250+
```
251+
252+
In the above example the 1st parameter `endpoint.Location.City` represents the field in the event record to query against. Other examples include `attributes.utm_campaign` or `endpoint.User.UserAttibrutes.custom` for example.
253+
254+
The 2nd parameter is a human readable label for the audience field.
255+
227256
## Required Infrastructure
228257

229258
A specific infrastructure set up is required to use this plugin:

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"description": "AWS Pinpoint Analytics integration for WordPress",
44
"type": "wordpress-plugin",
55
"require": {
6-
"aws/aws-sdk-php": "^3.103.0"
6+
"aws/aws-sdk-php": "^3.103.0",
7+
"johnbillion/extended-cpts": "^4.3.2"
78
},
89
"license": "GPL-2.0-or-later",
910
"authors": [

0 commit comments

Comments
 (0)