AdWords
6.2K members online now
6.2K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

Conversion tracking onclick when it opens a new window

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

We have a couple of examples were a conversion is actually an exit from the site.  The link opens in a new window/tab.  Also, for PDF links, we like to open PDFs in a new window/tab so the user can leave the PDF open and continue to browse the website.

 

How can you use the onclick Adwords Conversion Tracking functionality when the link opens a new window?  The default code which is called like 

<a onclick="goog_report_conversion
		('http://www.example.com/whitepapers/a.pdf')"
		href="#" >DOWNLOAD NOW</a>

uses window.location to redirect to the link after Google tracks the conversion.  So if you put target="_blank" in the link, it ends up opening the current page in a new window and loads the PDF that we're linking to in the current window.  Not the desired result obviously.

 

And it's not like we can update the goog_report_conversion code to open in a new window when a target is passed in because window.open will be popup blocked by most browsers.

 

Anyone have a strategy to make this work?  Or is it just not possible to track conversions on links that open to a new window/tab?


Thanks.

Marked as Best Answer.
Solution
Accepted by topic author Jason W
September 2015

Re: Conversion tracking onclick when it opens a new window

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆
Hi Jason

With Google Tag Manager you should be able to track that event and trigger an AdWords conversion accordingly: https://tagmanager.google.com

You would have to install the Google Tag Manager (GTM) container on your website (all pages) and configure GTM.

Cheers
Aleks

Re: Conversion tracking onclick when it opens a new window

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks Aleks,

That indeed will work because of the asynchronous nature of Google Tag Manager.

It's unfortunate that I just spend all this time updating my content to add Adwords Conversion Tracking everywhere only to find out that I can't track links that target a new window. This should really be in the conversion tracking documentation...

Jason

Re: Conversion tracking onclick when it opens a new window

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Maybe there is an solution without Google Tag Manager, you could try something like this:

 

<script>
function clickConv(link) {

var google_conversion_id = 0123456789;
var google_conversion_label = "abcdefghijklmnop";

image = new Image(1,1);
image.src="http://www.googleadservices.com/pagead/conversion/"+google_conversion_id+"/?label="+google_conversio...
alert("Conversion");
setTimeout(function() {
var win = window.open(link, '_blank');
win.focus()
}, 100);

}
</script>

<a onclick="clickConv('http://www.example.com/whitepapers/a.pdf')" href="#">DOWNLOAD NOW</a>

Re: Conversion tracking onclick when it opens a new window

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
this activates the browser's popup blocker. is there anyway to get around it without the tag manager and without blocking the popup blocker?

Thanks for any help in advance!

Conversion tracking onclick when it opens a new window

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi, I have solved in a different way and I publish it for future readers.

Instead of

 

<a onclick="return goog_report_conversion('http://www.example.com/whitepapers/a.pdf');" href="http://www.example.com/whitepapers/a.pdf" target="_blank">DONWLOAD NOW</a>

 

I wrote

 

<a onclick="return !window.open(this.href); return goog_report_conversion(this.href);" href="http://www.example.com/whitepapers/a.pdf">DONWLOAD NOW</a>

 

Et voila!! It works. I hope to help someone in the future and not to take him/her as much time to solve it as it took to me.