title: Using a dynamic <script> (a <script> appended to the DOM by JavaScript) to load and initialize Clicky Web Analytics
body: <p>I'm creating an HTML/JavaScript widget to be used on third-party sites. This widget is generated by a &lt;script&gt; that our customers will insert on their page. The &lt;script&gt; creates an &lt;iframe&gt; in the customer's domain, and then creates and inserts all of that &lt;iframe&gt;'s content using JavaScript.</p>
  
  <p>It's important that this &lt;iframe&gt; contain Clicky's tracking code to monitor clicks on outbound links. Unfortunately, I'm not having any luck getting Clicky to work when I append the requisite &lt;script&gt; elements to the &lt;iframe&gt; using JavaScript.</p>
  
  <p>I first tried simply appending the Clicky tracking code to the &lt;iframe&gt; after appending some test outbound links, hoping that Clicky could attach to those automatically as it does on a static page. That didn't seem to work, so my next inclination was to use the "advanced_disable" custom option and use clicky.log() on the links I want to track. Here's a link to a test page that's along those lines:</p>
  
  <p><a href="http://onespot.wsj.com/static/clicky_iframe_test.html" rel="nofollow noreferrer">http://onespot.wsj.com/static/clicky_iframe_test.html</a></p>
  
  <p>When clicking a link on that test page, the action is not logged in Clicky, and a JavaScript error appears:</p>
  
  <pre>clicky is not defined</pre>
  
  <p>This ("clicky") appears to be defined in <a href="http://static.getclicky.com/js" rel="nofollow noreferrer">http://static.getclicky.com/js</a>, which I confirmed through the Firebug console is indeed loading before I click a test outbound link.</p>
  
  <p>Has anyone successfully loaded Clicky in this way? If so, could you provide some sample code, a link to a working implementation, or some feedback on what's wrong with my code? I would also be interested to know if this is even possible.</p>
  
  <p>Thanks very much for any help or advice!</p>