My Oracle Support Banner

Location of Javascript Tags Change in Page Source from BODY to HEAD After Login or Refresh of Page Affecting Google Analytics Reporting (Doc ID 1518364.1)

Last updated on MARCH 08, 2017

Applies to:

Oracle WebCenter Portal - Version 11.1.1.5.0 to 11.1.1.6.4 [Release 11g]
Information in this document applies to any platform.

Symptoms

Trying to add the following javascript to the page template for Google Analytics, however we are seeing that accessing the Spaces Page in public view the code is placed into the BODY tag instead of the HEAD tag as it should. If you login to Spaces and access the same page and view the source you see the code in the HEAD tag which is correct. So the location is changing based on if your logged in or not.

The code added to the page template is as follows:

<af:resource type="javascript">

 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-34286622-1']);
 _gaq.push(['_trackPageview']);

 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();

</af:resource>

 




When we first access the page in a new browser (not logged in)  we see the javascript reference inside the BODY Tag.   After logging in we see the javascript reference has changed to the HEAD tag.

Google Analytics requires this code to always be in the HEAD tag for it to prove site ownership.



 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution
References

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.