Download the PHP package altis/aws-analytics without Composer

On this page you can find all versions of the php package altis/aws-analytics. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package aws-analytics

AWS Analytics

This plugin integrates WordPress with AWS Pinpoint and provides an extensible tracker out of the box.

It also automatically integrates with the WP Consent Level API plugin or the client side only version maintained by Human Made. At least the statistics-anonymous category must be consented to for any tracking to occur and statistics is required for tracking personally identifiable information.

Usage

In JavaScript

Once installed the plugin will queue up an analytics tracker script that provides a few client side functions you can use:

API

Altis.Analytics.onReady( callback <function> )

Use this function to ensure analytics has loaded before making calls to registerAttribute() or record().

Altis.Analytics.updateEndpoint( data <object> )

Updates the data associated with the current user. Use this to provide updated custom user attributes and metrics, a user ID, and demographic data.

Important: If used in conjunction with the WP Consent API all data passed to this function under the User property is removed. You should only store personally identifiable information under the User.UserId and User.UserAttributes properties. All other endpoint data as outlined further down should only be used for anonymous demographic data.

Altis.Analytics.getEndpoint()

Returns the current endpoint data object.

Altis.Analytics.record( eventName <string> [, data <object> [, endpoint <object>]] )

Records an event. The data passed in should be an object with either or both an attributes property and metrics property:

The optional 3rd parameter allows you to simulataneously update the endpoint data as if calling Altis.Analytics.updateEndpoint(). These attributes, metrics and endpoint data can be later queried via Elasticsearch.

Altis.Analytics.updateAudiences()

Synchronises the current audiences associated with the page session. You shouldn't ever need to call this manually but it is called any time updateEndpoint(), registerAttribute() or registerMetric() are called. You can hook into the updateAudiences event to respond to changes in this data.

Altis.Analytics.getAudiences()

Retrieves an array of the audience IDs for the current page session.

Adding global attributes and metrics

Altis.Analytics.registerAttribute( name <string>, value <string | callback> )

Sometimes you may want to record a dynamic attribute value for all events on the page. The registerAttribute() function allows this. Values must be a single string. If a function is passed as the value will be evaluated at the time an event recorded. Promises are supported as a return value.

Altis.Analytics.registerMetric( name <string>, value <number | callback> )

Similar to registerAttribute() above but for numbers.

Events

Altis.Analytics.on( event <string>, callback <callback> ) : EventListener

Attaches and returns an event listener. The available events and their callback arguments are:

Altis.Analytics.off( listener <EventListener> )

Removes an event listener returned by Altis.Analytics.on().

Constants

ALTIS_ANALYTICS_ELASTICSEARCH_URL

Allows you to define the Elasticsearch server URL directly.

ALTIS_ANALYTICS_LOG_QUERIES

Define as true to enable logging queries to the error log.

ALTIS_ANALYTICS_FALLBACK_CAPS

By default, Altis Analytics will grant any role who can edit pages the ability to edit audiences. You can explicitly remove the capabilities from a role (i.e. 'edit_audiences' => false), but in some cases you may wish to remove this fallback entirely.

Define as false to disable the capability fallback to page capabilities.

ALTIS_ANALYTICS_PINPOINT_BUCKET_ARN

If you have the Pinpoint Kinesis Firehose set to back up data to S3, defining this constant allows for data to be cleaned from the backups periodically.

ALTIS_ANALYTICS_PINPOINT_BUCKET_REGION

The region for the Kinsesis Firehose S3 bucket (if configured).

Filters

The plugin provides a few hooks for you to control the default endpoint data and attributes recorded with events.

altis.analytics.consent_enabled <bool>

This defaults to true if the WP Consent API plugin or a derivative is installed and active by checking if the constant WP_CONSENT_API_URL is defined.

altis.analytics.data.endpoint <array>

Allows you to provide server-side data used to update the visitors associated endpoint with custom attributes and demographic data. Mostly useful for providing extra data for logged in sessions such as IP based location data.

altis.analytics.data.attributes <array>

Allows you to provide server-side data recorded for all events on the page. Useful if you need to query records based on the page context.

altis.analytics.data.metrics <array>

Similar to the altis.analytics.data.attributes filter but allows you to pass metrics based on server-side data.

altis.analytics.data <array>

Filters the entire array passed to the client side.

altis.analytics.elasticsearch.url <string>

Filters the Elasticsearch server URL.

altis.analytics.noop <bool>

Returning false from this filter will prevent any events or updated endpoint data from being sent to Pinpoint. The built in usage for this is to prevent logging events on page previews.

altis.analytics.max_index_age <int>

Filter the maximum number of days to keep real time stats available for. The default number of days is the maximum of 90, after which data is removed. This is important for streamlining your user's privacy.

Insights and aggregated analytics data can be calculated, updated and stored in the database in cases where you wish to retain information for longer periods of time such as number of page views.

altis.analytics.max_s3_backup_age <int>

Filter the maximum number of days to keep backup data for. The default number of days is 90, in accordance with AWS Pinpoint, after which time data is removed. This is important for streamlining your users' privacy. There is no upper limit on this value, however you should make sure any long term data storage is explained to users when opting in to tracking.

altis.analytics.exclude_bots <bool>

This defaults to true but can switched off to allow tracking bots that can run JavaScript, note this will affect your data.

You can check if a recorded event was created by a bot by checking if the attributes.isBot value exists.

altis.analytics.elasticsearch.timeout <int> Filter the amount of seconds to wait for a repsonse from Elasticsearch. The default value is 20 seconds. The minimum value is 5 seconds and the maximum is 30 seconds.

Functions

Altis\Analytics\Utils\query( array $query, array $params = [] ) : array

Queries the analytics data with the Elasticsearch Query DSL provided in $query. $params will be added as query string parameters to the Elasticsearch request URL.

Altis\Analytics\Utils\get_elasticsearch_url() : string

Get the Elasticsearch server URL.

Altis\Analytics\Utils\milliseconds() : integer

Get the current time since the unix epoch in milliseconds.

Altis\Analytics\Utils\merge_aggregations( array $current, array $new, string $bucket_type = '' ) : array

A utility function for merging aggregations returned by Elasticsearch queries. This is necessary to keep a store of your analytics data as Elasticsearch indexes can be rotated or lost.

Querying Data

Data can be queried from Elasticsearch, providing a powerful tool for filtering and aggregating records. If you are using Altis requests are automatically signed.

It is recommended to use the Altis\Analytics\Utils\query() function for this.

Anatomy of an event record

A user session covers every event recorded between opening the website and closing it. For every event recorded the following data is recorded depending on the scope.

Time on page stats example

The output will look something like the following:

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.

Audiences

Audiences are user-defined categories of users, based on conditions related to their analytics data.

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.

Mapping Event Data

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:

In the above example the 1st parameter endpoint.Location.Country represents the field in the event record to query against. Other examples include attributes.qv_utm_campaign or endpoint.User.UserAttibrutes.custom for example.

The 2nd parameter is a human readable label for the audience field, and the 3rd is the human readable description that goes below the field UI.

The 4th parameter is an optional arguments array, which can include:

Required Infrastructure

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

Build process

To use the plugin from a direct clone you will need to run the build steps:

To use the dev server do:

Configuration

You must define the following constants:

Custom enpoints

If you wish to test locally you can use the following constants to override the service endpoints:

The humanmade/local-pinpoint and humanmade/local-cognito docker images provide a local version of the AWS Pinpoint API, limited to just the necessary methods.

You can then point the above endpoint constants to http://localhost:3000 and http://localhost:3001 respectively.


Made with ❤️ by Human Made


All versions of aws-analytics with dependencies

PHP Build Version
Package Version
Requires aws/aws-sdk-php Version ^3.103.0
johnbillion/extended-cpts Version ^4.3.2
markrogoyski/math-php Version ^0.51.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package altis/aws-analytics contains the following files

Loading the files please wait ....