Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Google Analytics Cloud Service Configuration inside the head element

Avatar

Level 3

I've successfully added the Google Analytics snippet as a Cloud Service Configuration (Generic Analytics Snippet) and it's being rendered by 

<sly data-sly-resource="${@ resourceType='cq/cloudserviceconfigs/components/servicecomponents'}" data-sly-unwrap/>

which is placed immediately before the </body> end tag as specified on https://docs.adobe.com/docs/en/aem/6-2/develop/personalization/target.html (The body Section (end)).

But Google recommends that "The code should be added before the closing </head> tag", https://developers.google.com/analytics/devguides/collection/analyticsjs/.

So what to do? Would I break it for other servicecomponents if I move it inside the head section or could I somehow specify that only the Google Analytics service configuration should be placed within the head section?

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

I would recommend you to follow official documentation here,

Link:- https://docs.adobe.com/docs/en/aem/6-2/administer/integration/external-providers.html

// Analytics with External Providers

You can configure your own instance of the Generic Analytics Snippets to define a new service configurations.

Creating a new Service with a Generic Snippet

1.Open the Tools console.

2.From the left pane expand Cloud Services Configurations.

3.Double-click on Generic Analytics Snippet to open the page

4.Click on the + to add a new configuration using the dialog; at a minimum assign a name, for example google analytics:

[img]https://docs.adobe.com/content/docs/en/aem/6-2/administer/integration/external-providers/_jcr_conten...

5. Click Create, the snippet dialog will open immediately - paste the appropriate javascript snippet into the field:

6. Click OK.

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

1 Reply

Avatar

Correct answer by
Administrator

Hi 

I would recommend you to follow official documentation here,

Link:- https://docs.adobe.com/docs/en/aem/6-2/administer/integration/external-providers.html

// Analytics with External Providers

You can configure your own instance of the Generic Analytics Snippets to define a new service configurations.

Creating a new Service with a Generic Snippet

1.Open the Tools console.

2.From the left pane expand Cloud Services Configurations.

3.Double-click on Generic Analytics Snippet to open the page

4.Click on the + to add a new configuration using the dialog; at a minimum assign a name, for example google analytics:

[img]https://docs.adobe.com/content/docs/en/aem/6-2/administer/integration/external-providers/_jcr_conten...

5. Click Create, the snippet dialog will open immediately - paste the appropriate javascript snippet into the field:

6. Click OK.

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni