Campaign CAE Integration

Last updated 2 months ago

Learn how to integrate Campaigns into the CAE.

This page gives you a short overview on how to integrate CoreMedia Campaigns into the CAE.

The CAE fetches and renders campaign data on content pages, category pages and product details pages.

Prerequisites

  • A CoreMedia Content Cloud account with CoreMedia Campaigns enabled.

  • Access to the Campaign App via Studio.

  • Valid access tokens for the Campaigns GraphQL Delivery API.

  • A CoreMedia Blueprint workspace version 2404 or higher.

Overview

The Campaign CAE Integration consists of two parts:

  • A plugin for the CAE

  • Blueprint extensions for the CAE.

The plugin is responsible for fetching the campaign data from the Campaign Delivery GraphQL API. The plugin is not part of the Blueprint and can be updated independently.

The Blueprint extensions are responsible for rendering campaign data into the page. The data is fetched from the Campaign Delivery Service per page impression with the given information of the current page, category or product. Once the slot assignment data is loaded from the Campaign Delivery Service it is rendered together with the page grid placements. This is achieved through a view hook integration for page grid placements. The CAE tries to render suitable campaign slot assignments for each placement on the page.

The FreeMarker templates for the rendering of campaign content are part of the Blueprint extension and the frontend workspace.

Configuration

Enable the Campaign Integration

To enable the integration in the CAE you need to:

  • Enable and configure the Blueprint extensions campaigns-cae and lc-campaigns-cae that are already part of the Blueprint workspace

  • Load the campaign.cae-plugin into your CAE

Extend your CAE configuration:

# Enables the Campaign CAE Integration
cae.campaign.enabled=true

# The access token for the Campaign Delivery API.
# Configure the preview access token in the preview CAE and the live access token in the live CAE
campaign.delivery.access-token=<your-campaign-delivery-access-token>

Load the campaign.cae-plugin into your CAE:

You can find the latest plugin releases here: campaign.cae-plugin releases. For further information on how to add plugins to your CAE please refer to the CAE documentation. (local development or Plugin Descriptors and Bundled Plugins)

Cache configuration (optional)

To avoid unnecessary requests to the Campaign Delivery API the CAE caches the campaign data. The cache is configured with the following configuration:

# Cache campaign data for one minute
cache.timeout-seconds.campaign.content=60

The default value is 10 seconds in the preview cae and 300 seconds in the live cae.

Check if the integration is working

  1. Open a page in the CAE.

  2. Create a new campaign in the Studio Campaign App for your site and the given page.

  3. Add a channel to the campaign (e.g. homepage).

  4. Add a slot assignment to the channel (e.g. banner). Make sure that the placement banner is rendered on the page.

  5. Reload the page. The campaign should be rendered on the page.

Development

CoreMedia provides a default template for the rendering of campaign content: CampaignSlot.ftl. It is part of the Blueprint extension campaigns-cae.

Customizing the Campaigns rendering

Rendering of campaigns is achieved by a view hook integration for page grid placements. In the template PageGridPlacement.ftl the view hook is called:

<@cm.hook id=bp.viewHookEventNames.VIEW_HOOK_PLACEMENT />

This triggers the CampaignPlacementViewHookEventListener that is part of the Blueprint extension. The view hook listener tries to find data for the current placement name in the campaign data. The campaign data has been fetched earlier and stored into the request via handler interceptors that are also part of the Blueprint extension.

If suitable data is found the view hook listener renders the data with the template CampaignSlot.ftl. The default render view for campaign slot assignments is asTeaser if the view has not been set in the view hook macro.

This can be customized by adding a view name as follows [source,freemarker

<@cm.hook id=bp.viewHookEventNames.VIEW_HOOK_PLACEMENT params={"view": "myView"} />

If you want to change the appearance of the campaign slot assignments, you can do so by changing the CampaignSlot.ftl template or adding a custom template with the same name to your own theme.

Copyright © 2024 CoreMedia GmbH, CoreMedia Corporation. All Rights Reserved.