Download the PHP package matfish/craft-optimum without Composer

On this page you can find all versions of the php package matfish/craft-optimum. 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 craft-optimum

Craft Optimum

IMPORTANT: Version 2.1.0 (Craft 5)/ 1.5.0 (Craft 4) introduces a breaking change. If you upgrade to this version, you will need to call optimumFireEvent explicitly in your twig template.

This plugin allows the user to conduct server-side A/B testing in CraftCMS. As opposed to client-side testing (e.g using Google Optimize), the test variant is rendered on the server-side, resulting in better UX, performance and enhanced flexibility.

Once an experiment is set you can send the data to your tracking platform and start tracking. By default, the event is sent for Google Analytics 4 as a custom dimension. You then have the full power of analytics to compare the test groups over different metrics (e.g conversion, engagement etc.)

If you are using a different analytics platform, you can still use the plugin to conduct the test, by passing a trackingPlatform or a custom fireEvent closure (the latter is useful for platforms that are not supported by Optimum).

Table of Contents

  1. Requirements
  2. Installation
  3. Usage
    • 3.1. Create an experiment in the control panel
    • 3.2. Create the variants in twig
      • Polymorphism
      • Explicit Declaration
      • Variant value only
    • 3.3. Fire the event
    • 3.4. Test your variants
  4. GA4 Setup (If applicable)
  5. Troubleshooting
  6. Caveats
  7. Local Development
  8. License

Requirements

Craft CMS 4.x or later.

Installation

  1. Include the package:

  2. Install the plugin:

Usage

1. Create an experiment in the control panel:

Click on the new "Experiments" menu item and then click on "New Experiment". An experiment consists of the following fields:

Wrap the part of code you wish to test (your "original" variant) with the {% optimum 'experimentHandle' %} tag like so:

Then create templates corresponding to each variant (except for "original") using the following naming convention: _optimum/{experimentHandle}/{variantHandle}.twig

E.g:

Inside each template paste the code for the variation you wish to test. E.g:

NOTE: Don't include the variant templates in your main template code. Optimum will automagically load the correct template at runtime.

Method B: Explicit Variant Declaration

While method A is useful when you want to switch components, sometimes you may wish to switch the location of the component on the page (e.g Test different CTAs positions). With method B, you can declare multiple optimum blocks with the second parameter being the variant:

E.g:

The plugin will only compile the relevant variant.

Method C: Get only variant value

In some cases there is no need to create multiple templates, as the value of the random variant can replace a constant in the code. E.g, Suppose you have a blog and want to test different per-page values. Here is an example implementation for a hypothetical (or is it?) recordsPerPage experiment:

3. Fire the event

Send experiment and variant to your tracking platform:

By default, this will send the event to GA4. e.g:

You can modify the tracking code by specifying a trackingPlatform or by overriding the fireEvent setting:

  1. Create a new file in your config folder called optimum.php
  2. Add the following code:

Or, if the platform is not supported by Optimum, you can specify a custom function:

NOTE: If you are using a tracking platform that is not currently supported by Optimum, we encourage you to share your custom tracking code implementation. This will help us expand our support for additional platforms in future updates, benefiting the entire community. Please consider submitting your custom tracking code example to the project repository or reaching out to the maintainer.

4. Test your variants

Now that everything is set up, the plugin will randomize a variant and persist it in a cookie, to keep the experience consistent per-user. You can test your variants (and the original) by adding a ?optimum={variant} query parameter to your URL. E.g ?optimum=wideBanner or ?optimum=original. The plugin will disregard the parameter if the value does not correspond to one of the variants.

Appendix: How to Set a Custom Dimension in GA4

This section assumes you are using the default ga4 tracking platform. For other platforms, please refer to the instructions for your specific tracking platform.

  1. Open GA for your property and go to Configure->Custom Definitions
  2. Click on the Create custom dimensions button
  3. In the modal fill in the following details:
    • Dimension Name : Descriptive name. Can be anything you want.
    • Scope : Event
    • Event parameter : Experiment handle (e.g bannerType).
  4. Click "Save"

    Screenshot 2023-07-14 094539

Et voila:

Screenshot 2023-07-14 094522 All Done! Once GA has collected enough data, you can start comparing the performance of the different cohorts/test groups:

custom-dimension

If using a different tracking platform, you will need to set up the tracking accordingly.

Troubleshooting

Before opening an issue please make sure that:

  1. Cookies are enabled
  2. Caching is disabled on the testable page (e.g Blitz), as plugin decides in real-time which variant to serve.
  3. If using GA4 for tracking: GTM is installed on the page (type gtag in the console to verify).

    Caveats

Local Development

When developing locally, if using GA4 tacking code, you are likely not going to have gtag installed, which will result in the following console error:

While there is no issue with ignoring this for development, for the sake of completion, and to see what arguments are being sent to GA, you may want to add a dummy gtag function in your <head> section:

You can use the same method to mock other tracking functions.

License

You can try Optimum in a development environment for as long as you like. Once your site goes live, you are required to purchase a license for the plugin. License is purchasable through the Craft Plugin Store.

For more information, see Craft's Commercial Plugin Licensing.


All versions of craft-optimum with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^5.0.0
ext-json Version *
nesbot/carbon Version ^2.58
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 matfish/craft-optimum contains the following files

Loading the files please wait ....