Google Analytics in ADF using javascript
867506Apr 20 2012 — edited Dec 4 2012Hi,
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.