Creating a Custom Cloud Service

The default set of Cloud Services can be extended with custom Cloud Service types. This allows you to inject custom markup into the page in a structured fashion. This will be primarily of use for 3rd party analytics providers, for example Google Analytics, Chartbeat, etc.
Cloud Services are inherited from parent pages to child pages with the ability to break the inheritance at any level.

Nota:

This step-by-step guide for creating a new Cloud Service is an example using Google Analytics. Everything might not apply to your use case.

In CRXDE Lite, ceate a new node under /apps:

Name: acs

Type: nt:folder

Create a new node under /apps/acs:

Name: analytics

Type: sling:Folder

Create 2 new nodes under /apps/acs/analytics:

Name: components

Type: sling:Folder

and

Name: templates

Type: sling:Folder

Right click on/apps/acs/analytics/components. Select Create... followed by Create Component... The dialog that opens allows you to specify:

Label: googleanalyticspage

Title: Google Analytics Page

Super Type: cq/cloudserviceconfigs/components/configpage

Group: .hidden

Click Next twice and specifiy:

Allowed Parents:acs/analytics/templates/googleanalytics

Click Next twice and click OK.

Add a property to googleanalyticspage:

Name:cq:defaultView

Value:html

Create a new file named content.jsp under /apps/acs/analytics/components/googleanalyticspage, with the following content:

Create a new node under/apps/acs/analytics/components/googleanalyticspage/:

Name: dialog

Type: cq:Dialog

Properties:

Name: title

Type: String

Value: Google Analytics Config

Name: xtype

Type: String

Value: dialog

Create a new node under/apps/acs/analytics/components/googleanalyticspage/dialog:

Name: items

Type: cq:Widget

Properties:

Name: xtype

Type: String

Value: tabpanel

Create a new node under/apps/acs/analytics/components/googleanalyticspage/dialog/items:

Name: items

Type: cq:WidgetCollection

Create a new node under/apps/acs/analytics/components/googleanalyticspage/dialog/items/items:

Name: tab1

Type: cq:Panel

Properties:

Name: title

Type: String

Value:Config

Create a new node under/apps/acs/analytics/components/googleanalyticspage/dialog/items/items/tab1:

Name: items

Type: nt:unstructured

Properties:

Name:fieldLabel

Type: String

Value: Account ID

Name: fieldDescription

Type: String

Value: The account ID assigned by Google. Usually in the form UA-NNNNNN-N

Name: name

Type: String

Value: ./accountID

Name: validateOnBlur

Type: String

Value: true

Name: xtype

Type: String

Value: textfield

Copy /libs/cq/cloudserviceconfigs/components/configpage/body.jsp to /apps/acs/analytics/components/googleanalyticspage/body.jsp and change libs to apps on line 34 and make the script reference on line 79 a fully qualified path.