Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Google Analytics in ADF using javascript

867506Apr 20 2012 — edited Dec 4 2012
Hi,

I am trying to use the Google Analytics in my application, for that I embedded a piece of javascript under af:document tag

<af:resource type="javascript">
var gaq = gaq || [];
gaq.push(['setAccount','UA-30968558-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>

The Google Analytic Id varies per instance so I created a view object to get the google analytics id. Instead of hard coding the Id I want to dynamically bind the value.


I tried the following
<af:resource type="javascript">
var gaq = gaq || [];
var gaId;
gaId = document.getElementById("gaId");
gaq.push(['setAccount','gaId' ]);
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>

<af:inputText value="#{bindings.Googleanalyticsid.inputValue}"
id="gaId"
contentStyle="100%" visible="false">
</af:inputText>

For some reason the page is not displaying correctly.


Could anyone help me out.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2013
Added on Apr 20 2012
3 comments
975 views