Load an iFrame to Drupal with JavaScript Because of Google Analytics I would need to use JavaScipt to load iFrame to my Drupal template. I use this only just on one custom content type template.

Can I put the JavaScript straight to the template?

At the moment the JavaScript in my node template is like this:

&lt;script type="text/javascript"&gt;
var iframe = document.getElementById('myIFrame');
iframe.src = pageTracker._getLinkerUrl('http://mydomain.com/iframepage/');

&lt;/script&gt;

&lt;iframe id="myIFrame" height="500px" width="350"&gt;&lt;/iframe&gt;


But it doesn't load anything to the iFrame. I followed this http://code.google.com/intl/fi/apis/analytics/docs/tracking/gaTrackingSite.html#trackingIFrames

Any idea where the problem is?

EDIT: noticed that I get error: "Uncaught ReferenceError: pageTracker is not defined"
Your code is missing some important stuff. The original code from the Google page you linked yourself:

_gaq.push(function() {
  var pageTracker = _gat._getTrackerByName();
  var iframe = document.getElementById('myIFrame');
  iframe.src = pageTracker._getLinkerUrl('http://www.my-example-iframecontent.com/');
});


So you would end up with something like the following.

&lt;script type="text/javascript"&gt;_gaq.push(function () {
  document.getElementById('myIFrame').src = _gat._getTrackerByName()._getLinkerUrl('http://www.my-example-iframecontent.com/');
});&lt;/script&gt;
&lt;iframe id="myIFrame" height="500px" width="350"&gt;&lt;/iframe&gt;