AdWords
5.8K members online now
5.8K 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 on button click?

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

I know there is a solution for tracking button clicks however I couldn't find a way to make it work with target="_blank".

 

I have already read this page: https://support.google.com/adwords/answer/6095821#get_tag

It says that I should use the code like this:

 

<img src="download_button.gif" alt="Download Whitepaper"
		width="32" height="32"
		onClick="goog_report_conversion
		('http://www.mysite.com/whitepapers/a.pdf')"/>

 

However I want my affiliate link to open in a new window. If I add target="blank" to the code then it won't behave as expected. Instead of the homepage staying intact and the affiliate link opening in a new window, it instead opens the homepage in a new window and the affiliate link opens in the first window (it replaces the homepage). I hope you understand my problem and there is a solution for this?

3 Expert replyverified_user

Re: Conversion tracking on button click?

Follower ✭ ☆ ☆
# 2
Follower ✭ ☆ ☆
Please, show your code.

Re: Conversion tracking on button click?

Top Contributor
# 3
Top Contributor
Hi Robert B,

That doesn't look like all of the code. This is an image tag, not a button tag. The onClick function here should record the conversion, but it will not initiate a download. My bet is there is a link tag surrounding this image. The target should be within the link tab.

This is wrong: target="blank"
This creates a new window named "blank".
Subsequent clicks on this link will open the page in that window
and will not create a new window

This is right: target="_blank"
This creates a new window.
Subsequent clicks on this link will continue to open a new window

Which page it opens depends on the href property of the link tag.

This is all guessing at how your page works. If you post the page URL, we can look at the source and try to find out what's going on, or, as Darts P suggested, post all of the code involved.

Best of Luck!

Pete

petebardo -- Deadhead doing AdWords

Re: Conversion tracking on button click?

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hi,

Sorry I don't want to share my site, but here is the code. My problem is that the target="_blank" is not working correctly. You can test it yourself.

So my quesiton is: how can I track button clicks with target="_blank"?


<body>
<!-- Below is a sample link for a file download.
You need to replace the URL for the file and the
DOWNLOAD NOW text with the text you want to hyperlink. -->
<a onclick="goog_report_conversion
('http://www.example.com/whitepapers/a.pdf')"
href="#" target="_blank" >DOWNLOAD NOW</a>


<!-- Google Code for Add to Cart Conversion Page
In your html page, add the snippet and call goog_report_conversion
when someone clicks on the chosen link or button. -->
&lt;script type="text/javascript">
/* <![CDATA[ */
goog_snippet_vars = function() {
var w = window;
w.google_conversion_id = 12345678;
w.google_conversion_label = "abcDeFGHIJklmN0PQ";
w.google_conversion_value = 13.00;
w.google_conversion_currency = "USD";
w.google_remarketing_only = false;
}
// DO NOT CHANGE THE CODE BELOW.
goog_report_conversion = function(url) {
goog_snippet_vars();
window.google_conversion_format = "3";
var opt = new Object();
opt.onload_callback = function() {
if (typeof(url) != 'undefined') {
window.location = url;
}
}
var conv_handler = window['google_trackConversion'];
if (typeof(conv_handler) == 'function') {
conv_handler(opt);
}
}
/* ]]> */
&lt;/script&gt;
&lt;script type="text/javascript"
src="//www.googleadservices.com/pagead/conversion_async.js">
&lt;/script&gt;
</body>
</html>

Re: Conversion tracking on button click?

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
let me put it simpler: All I want is to track clicks as conversions to third party website. This means that I will not have a page where you add the conversion code.

Re: Conversion tracking on button click?

Top Contributor
# 6
Top Contributor

Hi @Robert B are you using Google Tag Manager?  It's very simple to add conversion code (or a GA event) that fires on a specific link click.

 

https://support.google.com/tagmanager/answer/3415369?hl=en

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

Re: Conversion tracking on button click?

Rising Star
# 7
Rising Star
Hi Robert, you can track specific clicks as conversions using combination of Google Analytics and Tag manager. You can create an Google Analytics event in Tag Manager, for example click on specific button and create a goal based on this event. If you have linked Google Analytics and Adwords, you will see these conversions inside adwords system.

That's the easiest approuch I have discovered so far.
Cheers, Alexey
UAWC Agency
Did you find any helpful responses or answers to your query ? If yes, please mark it as the ‘Best Answer.’

Re: Conversion tracking on button click?

Top Contributor
# 8
Top Contributor
Hi Robert B,

This is what you posted:
<!-- Below is a sample link for a file download.
You need to replace the URL for the file and the
DOWNLOAD NOW text with the text you want to hyperlink. -->
<a onclick="goog_report_conversion
('http://www.example.com/whitepapers/a.pdf')"
href="#" target="_blank" >DOWNLOAD NOW</a>

What this should do is open the same page in a new window. It should also record the click as a conversion.

It should probably look like this instead:

<!-- Below is a sample link for a file download.
You need to replace the URL for the file and the
DOWNLOAD NOW text with the text you want to hyperlink. -->
<a onclick="goog_report_conversion
('http://www.example.com/whitepapers/a.pdf')"
href="http://www.example.com/whitepapers/a.pdf" target="_blank" >DOWNLOAD NOW</a>

The comment instructs, "You need to replace the URL for the file " That URL goes in the href property of the link. What you enter for goog_report_conversion is used for identification of the conversion.

Whether downloads or displays the pdf depends on the mime type. I will assume that is correct.

Best of Luck!

Pete

petebardo -- Deadhead doing AdWords

Re: Conversion tracking on button click?

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭
I tried this as well. If you try it on a live site, not localhost, you will see that this code open a new tab but also replaces the current tab with the target link.

Re: Conversion tracking on button click?

Top Contributor
# 10
Top Contributor
Hi Robert B,

I dummied up a page here: http://www.astronautcentral.com/testURL.html

You can look at the source if you want. goog_report_conversion() is just s stub here that returns true.

When you first load the page, you'll get an alert "Load Page". This is here to determine whether the page loads again. Click on the link and it will open a new window (or tab) with a pdf. The mime type for the pdf does not trigger a download, instead it displays the pdf. That may make a difference.

When you click on the link, The page will go blank, then display. I inserted the page load alert to determine whether it actually loads the page.

After I got the mime type and content-disposition properties right, This opened a new tab and initiated a download on the new (blank) page. So, I removed the target and tried again. (http://www.astronautcentral.com/testURL2.html). This initiated the download without loading a new page.

I tested with Firefox, but it reports the .pdf mime type as application/pdf instead of application/download. I suspect this is a local caching problem. I tried again with Chrome and it works as expected.

Try the 2 pages and see what you get. If the download is initiated properly without reloading the page, decide whether you really want to use a target for the link, and closely inspect the spelling and syntax of the tag.

If that doesn't work, check back in and I'll take another stab at it.

Pete
petebardo -- Deadhead doing AdWords