Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Analytics & Adwords delayed javascript link to App Store ignored?
    text
    copied!<p>I'm trying to measure conversion for both my Google Adwords campaign and normal traffic going to the App Store. Previously I had a link "/app_store/" on my page that would load, wait 1 second and then continue to the app store. </p> <p>I found a more elegant solution somewhere using Javascript. For adwords it loads a pixel image and for analytics it calls a Google Javascript function, pauses for a fraction of a second and then follows the link. </p> <p>Unfortunately it's not working for me. Google Analytics and Google Adsense don't see anyone going to the App Store (not even myself).</p> <pre><code>&lt;script type="text/javascript"&gt; var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-18180332-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); })(); function recordOutboundLink(link, category, action) { try{ // Google Analytics var pageTracker = _gat._getTracker("UA-18180332-1"); pageTracker._trackEvent(category, action); // Google Adwords var image = new Image(1, 1); image.src = "http://www.googleadservices.com/pagead/conversion/1046551421/?value=$8&amp;amp;label=zqrfCMWh0QEQ_baE8wM&amp;amp;guid=ON&amp;amp;script=0" setTimeout('document.location = "' + link.href + '"', 100) } catch(err) {} } &lt;/script&gt; </code></pre> <p>And for the link:</p> <pre><code>&lt;a href="http://itunes.apple.com/ae/app/isimplifiedchinese/id377690407?mt=8" onClick="recordOutboundLink(this, 'Outbound Links', 'http://itunes.apple.com/ae/app/isimplifiedchinese/id377690407?mt=8');return false;"&gt; &lt;img alt="Appstore" src="images/appstore.png"&gt;&lt;/a&gt; </code></pre> <p>What am I doing wrong here?</p> <p><strong>Update 23:13</strong> I noticed that if the delay is 100ms, the following error flashes by (it took me a while to time the screenshot).</p> <p><img src="https://i.stack.imgur.com/0UV87.png" alt="Failed to load resource"></p> <p>I only tested this with Erwan's suggestion; not sure if it also happened in the old version. The error seems to go away for longer delays; I set it to 300ms to be on the safe side.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload