Google Analytics Cloud Service Configuration inside the head element | Community
Skip to main content
AEMing
New Participant
August 17, 2016
Solved

Google Analytics Cloud Service Configuration inside the head element

  • August 17, 2016
  • 1 reply
  • 1126 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

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_content/contentbody/procedure/proc_par/step_2/step_par/image.img.png/1335437851000.png[/img]

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

1 reply

kautuk_sahni
kautuk_sahniAccepted solution
Employee
August 19, 2016

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_content/contentbody/procedure/proc_par/step_2/step_par/image.img.png/1335437851000.png[/img]

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