Sitemap
Tech Learnings

Everything about Tech learnings — Coding,Design, tutorials and more learnings

Adobe Experience Manager: Enable Gated Content in AEM

6 min readSep 18, 2020

--

In this tutorial, I am going to explain what is gated content and different approaches to enable the gated content in AEM

What is Gated Content?

Gated content is any content that is hidden behind a lead capture form or authentication. To access the content, a user must provide personal information, usually in the form of an email address, phone number, job title, etc, or registering by providing the required basic information and authenticating to the system. Gates are highly valuable to marketers because they are powerful tools for lead generation.

I am going to explain two different approaches to enable the gated content in AEM — Closed User Group(CUG) and content behind a lead form.

Closed User Group(CUG)

Closed User Groups (CUGs) is a feature used to restrict access to content to a select group of users on a published site. When you assign CUG to a page, that page requires a login and only CUG admitted users are allowed to access that page. Both Closed User Groups (CUG) and Access Control Lists (ACL) are used to control access to content in AEM and based on AEM Security users and groups.

By enabling the CUG with the required ACL for specific content or asset, the access to the content/assets can be restricted only for the registered/authenticated users with required permissions.

Let us now enable the CUG.

As a first step create a user group e.g wknd-magazine-readers and enable the read permission for the required content hierarchies. Create a sample user and add to wknd-magazine-readers

Press enter or click to view image in full size
Press enter or click to view image in full size

Activate the test users so that is available in the publish environment.

Activate the closed user group “wknd-magazine-readers” so that it is available in the publish environment

Open the properties of the page that required the CUG enabled.

Advanced → “Enable” “Authentication Requirement”

Configure the Login Page — I am using the default login page(http://localhost:4502/libs/granite/core/content/login.html) for real-time scenarios you can have a custom login page or external login page

Press enter or click to view image in full size

Now enable the admitted user groups under the “Permissions” tab.

Press enter or click to view image in full size

Activate the page so that it will be available in publisher, now the users should register(request the minimal details required to access the page) and login to access the CUG enabled content, whenever the user registers add the user to the corresponding user group e.g wknd-magazine-readers group so that they will have the access to restricted content — the content is accessible only by the users part of the CUG group(wknd-magazine-readers)

By default, the authentication enabled pages(including CUG) are not cached in Dispatcher(/allowAuthorized “0”), f you want cache CUG enabled content, you should use the permission sensitive caching (PSC) feature of the dispatcher.

Gated Content through the Lead form:

The gated content is configured by enabling a lead form in front of the content, user should fill the lead form with minimum details to get access to the gated content, the content is accessible only by filling the Lead form.

Overall the gated content follows the below simple logic

Press enter or click to view image in full size

While accessing the gated content the user will be presented with a lead form if not already filled, upon filling the form the user will be redirected to the final gated content. if the user already filled the form will be directly redirected to the final gated content. The lead form should be hidden from Search Engines so that no one directly accesses the form but in case they access the form directly the user will be redirected to the default redirect page configured in the form upon filling the data.

The implementation workflow is going to be as below

Press enter or click to view image in full size

Modified the Page component dialog to enable the Gated Access tab along with required details

Refer https://github.com/techforum-repo/youttubedata/blob/master/gatedcontent/ui.apps/src/main/content/jcr_root/apps/gatedcontent/components/page/_cq_dialog/.content.xml

Press enter or click to view image in full size

Created a Sling Filter along with a service that will redirect the user to the configured form URL, if the resource is gated and the lead form was not already filled based on the availability of the cookie with the form name— the gated content path will be added as a query parameter while redirecting to the form.

Refer to https://github.com/techforum-repo/youttubedata/blob/master/gatedcontent/core/src/main/java/com/gatedcontent/core/filters/GatedContentFilter.java

https://github.com/techforum-repo/youttubedata/blob/master/gatedcontent/core/src/main/java/com/gatedcontent/core/services/GatedContentService.java

I am using the core form components to enable the gated form, created a new action(gatedredirect) along with a custom service to support the gated form action (if you use the custom form handling change the logic accordingly)— the “gatedredirect” action process the form data and redirect the user to the gated URL specified in the referer header or the default URL configured in the form by adding a cookie value based on the form name.

Refer to https://github.com/techforum-repo/youttubedata/tree/master/gatedcontent/ui.apps/src/main/content/jcr_root/apps/foundation/components/form/actions/gatedredirect

https://github.com/techforum-repo/youttubedata/blob/master/gatedcontent/core/src/main/java/com/gatedcontent/core/services/GatedFormDataProcessor.java

Press enter or click to view image in full size

Refer the below GitHub URL for the complete reference code

To enable the gated content, as a first step create a Lead form with required fields and configure the “gatedredirect” action in the Form Container

Press enter or click to view image in full size

Action Type — “Gated Redirect”

Form Name — Enter a unique form name, the same form name should be used while enabling the Gate for the content.

Default Redirect Location — Enter a default redirect location that will be used in case someone accesses the form directly.

Press enter or click to view image in full size

Now enable the Gate for the required content page

Select “Enable Gated Access”

Form Name — Enter the form name e.g “testForm”, the same form name used while configuring the “gatedredirect” action in the form

Form Location — Enter the Lead form location

Press enter or click to view image in full size

Now while accessing the gated content(/content/gatedcontent/us/en.html) the user will be presented with a lead form if not already filled, upon filling the form the user will be redirected to the final gated content. if the user already filled the form will be directly redirected to the final gated content.

The gated content helps the marketers to increase the lead generations, the above solution can be extended to enable the gate for assets.

Feel free to provide your comments

--

--

Tech Learnings
Tech Learnings

Published in Tech Learnings

Everything about Tech learnings — Coding,Design, tutorials and more learnings

Albin Issac
Albin Issac

Written by Albin Issac

I work as a Software Architect specializing in Marketing Technologies. For more information, please visit my profile at: https://myprofile.albinsblog.com/

No responses yet