Experimental project

This is a sandbox project, which contains experimental code for developer use only.

About

The Personalized Block module provides a recipe for creating an authoring experience for personalizing content in Drupal, which integrates with an external personalization engine.

This module’s approach is to leverage Drupal’s Block system with the Paragraphs module to create “personalized blocks” that allow site builders to create multiple variations of content displayed based on personalization rules defined and managed in an external personalization engine.

Assumptions

One key assumption is the personalization rules are applied using clientside JavaScript. This assumption allows organizations to override the personalized_block.js file to execute requests to an external personalization engine’s API. The personalization engine’s API would recommend which variant should be displayed in a personalized block.

The external personalization engine's rules need to support defining context (i.e., homepage, landing page, blog post, etc.) with a list of possible variants (i.e., new user, returning user, authenticate user, etc.).

Demo

The Personalized Block Demo module provides examples of personalized blocks display in the Bartik theme. The Bartik theme is required to install the demo. The default clientside JavaScript will display the corresponding variant if the variant id is appended to the page's URL as the query string (i.e., ?_variant=my-variant-id). For example, in the demo module, you can append the letters a, b, or c or the number 1,2, or 3 to the URL (i.e., https://localhost/?_variant=a or https://localhost/?_variant=1) to trigger one of the personalized block's variants.

Downloading and Installation

The Personalized Block module is currently under development as a sandbox module. To install this sandbox module, you will need to update your project's composer.json file to include the below repository and require statements. Learn more about installing sandbox modules.

{
    "repositories": {
        "drupal/personalized_block": {
          "type": "package",
          "package": {
              "name": "drupal/personalized_block",
              "type": "drupal-module",
              "version": "1.0.x-dev",
              "source": {
                  "url": "https://git.drupalcode.org/sandbox/bronzehedwick-3227437.git",
                  "type": "git",
                  "reference": "1.0.x"
              }
          }
       }
    },
    "require": {
        "drupal/personalized_block": "1.0.x-dev"
    }
}

After running composer update, you can install the Personalized Block module via the Extend page (/admin/modules) or using Drush (drush enable -y personalized_block or drush enable -y personalized_block_demo).

Steps to review

Personalized Block

Install the Personalized Block module.

  • /admin/modules

Confirm the 'Personalized Block' and 'Personalized HTML' block content types are added.

  • /admin/structure/block/block-content/types

Click 'Add custom block' and select a 'Personalized Block' or 'Personalized HTML' block.

  • /admin/structure/block/block-content

Place the custom block in second sidebar.

  • /admin/structure/block

Confirm the custom block is appearing on the website.

  • /

Confirm a custom block variant is displayed with the corresponding query string.

  • /?_variant=variant-id

Personalized Block Demo

Install the Personalized Block Demo module.

  • /admin/modules

Confirm the personalized block example default content is displayed as 0.

  • /

Confirm the personalized block example variant content is displayed as 1.

  • /?_variant=1

Confirm the personalized HTML example default content is displayed as X.

  • /

Confirm the personalized HTML example variant content is displayed as A.

  • /?_variant=a

Related/Similar Modules

References

Supporting organizations: 

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • Module categories: Content Editing Experience
  • Created by bronzehedwick on , updated