How to Track Clicks as Conversions in Adwords
Tags: AdWords, event based conversions
In some cases (affiliates, third party integration) you may need to track AdWords conversions that are happening as events (clicks that are redirect visitor to athird party websit) and not as pageview conversions. As per April 2010, Adwords is counting conversions only when a page which contains the tracking code is viewed by visitors. If you’re sending traffic to a website but the conversion is happening on another website or if there is no page that loads after users take the desired action on the website (e.g. when downloads are automatically starting on clicks on Download Now, or at clicks on installing firefox plugins) you still can count the AdWords conversions as event-based conversions. I will exemplify how to track non-page view conversions by looking at click on a Dowload Now button.
Step 1
On all pages where you want to track clicks on the Download Now button, add the following JavaScript code to the <head> section.
<script type=”text/javascript”> function setIframe() {var pitstopmedia = document.getElementById(‘psm’).innerHTML = ‘<iframe src=”tracking.html” style=”border:none;width:1px;height:1px;” marginheight=”0″ marginwidth=”0″ frameborder=”0″></iframe>’;} </script>
Step 2
Add the following onlick event to each download now link/button/image
onclick=”setTimeout(setIframe,2000);”
and right after each download link/button insert the following <div>
<div id=”psm” style=”display:none;”></div>
For example, if your initial download now link looked like
<a href=”http://www.samplesite.com/download/software.zip”> <img src=”http://www.samplesite.com/images/but-download-big.png” alt=”download” width=”234″ height=”63″ border=”0″></a>
After adding the onlclick and the div your download links should look like:
<a href=”http://www.samplesite.com/download/software.zip” onclick=”setTimeout(setIframe,2000);”><img src=”http://www.samplesite.com/images/but-download-big.png” alt=”download” width=”234″ height=”63″ border=”0″> </a> <div id=”psm” style=”display:none;”></div>
Step 3
Create a html file called tracking.html and save it at the location specified by the iframe from Step 1 (src=”tracking.html) and paste your AdWords conversion tracking code in the file. The html file will contain just the Adwords tracking code, something similar too:
You’re done! If correctly implemented, the script will open an invisible iframe that contains the AdWords (or any other tracking code) at each click on the Download Now button. Since the iframe is going to load in the browser, thus generating a fake page view, your Adwords conversion code will be triggered and you should see conversions in your Adwords reports.
Pitstop Media offers ROI based internet marketing services. If you need help with PPC management or PPC optimization please contact us for a free, no obligation quote. We’ve helped companies reduce their paid advertising cost by as much as 48% and increase AdWords conversion rates by as much as 410%. See our internet marketing case studies.




Maria said:
Jun 16, 10 at 5:56 amVery helpful, thanks!
I’m wondering, though, if not the onclick is missing from your example in step 2?
Would it look like the following? (with < instead of {)
{a href=”http://www.samplesite.com/download/software.zip” onclick=”setTimeout(setIframe,2000);”}{img src=”http://www.samplesite.com/images/but-download-big.png” alt=”download” width=”234″ height=”63″ border=”0″}{/a}
Also, in step 1, wouldn’t you have to replace the “var pitstopmedia = document.getElementById(‘psm’).innerHTML” with something referring to your own site?
Thanks for your help!
TraiaN said:
Jun 16, 10 at 8:49 pmthanks for correcting the error Maria. Indeed on step 2 I missed the onclick event. I will update the post at once.
Also, in step 1 you can use whatever name you like for that variable and it doesn’t have to be related to yourwebsite name.
ps said:
Jun 19, 10 at 8:58 pmjust a note for noobs like me – i cut and pasted the code from the article above into my html files – BUT, all of the single and double quotemarks are “real” ones (like when you select smart quotes in your word processor) – you have to change these back into the type code expects yourself after pasting.
i was wondering why this wasn’t working for me for 2 days now, even though analytics said people were clicking on the button. hopefully this fixes the problem for me. fingers crossed!
TraiaN said:
Jun 21, 10 at 10:10 amWhen you copy and paste from pure html documents (which are blog is) the quotes are modified from straight quotes ” to round quotes ” which is not what you want. You need to replace all rounded quoted with straight ones, directly in a text editor (notepdad or notepad++) and then copy and paste our sample code into your documents. In the same way you need to replace ‘ and ’ with ‘.
Mikhail Silin said:
Jul 16, 10 at 6:33 pmThanks for the script, exactly what I needed.
Mikhail Silin said:
Jul 16, 10 at 7:03 pmQuestion: will this work if I’m embedding into a paypal form which is all in form tags?
looks something like this:
”
Options
Test $20.00
Test 2 $25.00
Test 3 $30.00
”
I assume you put the onclick code into the image input tags… but is the only problem that results that the iframe will pop up?
Mikhail Silin said:
Jul 16, 10 at 7:06 pmSorry repost b/c the form didn’t work… set }
{tr}{td}{input type=”hidden” name=”on0″ value=”Options”}Options{/td}{/tr}{tr}{td}{select name=”os0″}
{option value=”Test”}Test $20.00{/option}
{/select} {/td}{/tr}
{/table}
{input type=”hidden” name=”currency_code” value=”USD”}
{input type=”image” onClick=”TTSPaypal()” src=”https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif” border=”0″ name=”submit” alt=”PayPal – The safer, easier way to pay online!”}
{img alt=”" border=”0″ src=”https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif” width=”1″ height=”1″}
{/form}
I assume you put the onclick code into the image input tags… but is the only problem that results that the iframe will pop up?
TraiaN said:
Jul 19, 10 at 1:29 pmMikhail, did you test the implementation already? The iframe should not open, since it has a display:none attribute in css. let me know if it worked.
Mikhail Silin said:
Jul 21, 10 at 8:16 pmThe iframe didn’t open but Google didn’t count the conversion either. Back to the drawing board.
TraiaN said:
Jul 21, 10 at 9:49 pmadd event tracking on the same link, using Google Analytics and see if clicks are tracked.
Mikhail Silin said:
Jul 23, 10 at 4:50 pmI figured out the problem – when I copied your source code, there is a space in step one between src and =, which I didn’t delete. Stupid mistake. It works fine now. Thanks for this! It will help my tracking immensely.
TraiaN said:
Jul 23, 10 at 6:01 pmThanks, I’ve removed the space now. Sometime yes, you get big headaches from small issues.
Adam said:
Aug 19, 10 at 9:41 pmIf there is more than 1 link on a page, does the still need to appear after each or could it appear once at the end of the page?
TraiaN said:
Aug 20, 10 at 10:55 amyes, if you need to track multiple links, you will have to add the onclick event to all href anchors
Patrick said:
Aug 27, 10 at 7:17 amInteresting approach to tracking links as conversions in Adwords. I’ve got a question about using this along with regular GA event tracking.
Say I’ve got an outbound link that I need tracked in GA, but that we also have an Adwords conversion set on this outbound URL (so it gets counted a a click to that URL and also gets counted as someone coming to the site via Adwords and clicking on that URL).
How would you implement both? Is that possible?
TraiaN said:
Aug 27, 10 at 11:33 amPatrick, it is possible. The javascript will call 2 functions the event tracking for GA and the iframe. This is what we use for one client of us
This way we track events in Google Analytics and conversions in AdWords.
The Flower Guy said:
Dec 31, 10 at 3:08 pmI created a jquery plugin a while back that does this and (IMHO) is a little simpler. see http://favcode.net/browse/jquery_plugin_for_google_adwords_conversion_tracking for the plugin code and an example of usage.
Siku-Siku said:
Jul 07, 11 at 10:06 pmThanks for the detailed workaround.
For the step #2, we might want to apply the setTimeout on when the browser should follow the link (i.e. not on the setIframe function). Basically, we want to make sure the setIframe function completes its execution before following the link.
Reference: http://bit.ly/pfAHFl
The code above doesn’t prevent the browser to immediately follow the link. Thus, there is a chance that setIframe function doesn’t get executed.
TraiaN said:
Jul 08, 11 at 9:56 amthanks for the comment. I’ve tried setTimeout, but for some reason I was not able to get it working
Bruno said:
Jul 19, 11 at 10:53 amIf you are using google analytics you could also just track clicks as events, make events goals and do the GA to AdWords goal import.
TraiaN said:
Jul 19, 11 at 11:14 amyes, you could do that, but then you will have to deal with different cookie lives.
Christian Due said:
Nov 08, 11 at 3:07 amDear TriaN
It’s just what i have been looking for :) I need it for both adwords and A/B test tracking but I just can’t get it to work. (Only trying adwords right now)
Can you look through it for me?
I implemented it here:
http://super-abonnementer.dk/iphone-4s-kob
On the first button on the right side saying “til butik”
Looked though it a couple of times and just can’t figure it out.
My iframe is here: http://super-abonnementer.dk/tracking.html
Thanks
Christian
TraiaN said:
Nov 10, 11 at 4:29 pmChristian, I don’t the the onClick event on your anchor.
Alan said:
Dec 02, 11 at 5:37 amI was wondering whether it woudl work calling the ‘call’ code that is generated by Adwords if you select ‘call’ rather than webpage. My Javascript is a bit basic, but it appears it might do the job.
/* */