AdWords
2.4K members online now
2.4K 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

Tracking multiple conversions on the same html page

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi guys,

 

I've recently posted a question on stackoverflow regarding adwords conversions. I haven't solved the issue yet and I'll post it here as well (I hope that's ok) in order to see if someone can help and because it might be useful to other members of the community as well Smiley Happy.

 

Here's the content of the stackoverflow post:

 

"I've got an adwords desktop landing page on which I would like to track clicks on multiple tags as conversions. I've contacted adwords' support by phone and they told me it's not possible.

 

However, I've seen this relatively old post on stackoverflow  which has an accepted answer. I've had a look and google's js scripts provided in the post have a totally different structure from the ones I get when creating a new conversion in my adwords account.

 

Is it an old version of the Google code or maybe a version for mobile only ? If yes, is it still possible to track multiple conversions on the same page ?

 

The main issue I have with the code I currently get from adwords is that the only parameter in the goog_report_conversion() function is url. Hence, if I have several js snippets, each for its own conversion, how can adwords know which tag is supposed to call which js snippet based only on the url parameter (I guess it can't) ?

 

Does adwords have a more sophisticated version for developers where you have more options ?

 

Would it work if I change the names of the goog_report_conversion() function in each js snippet and associate to each tag its now unique function ? Or would it totally "break" the code ?"

 

Thanks in advance,

 

M.C.

2 Expert replyverified_user

Re: Tracking multiple conversions on the same html page

Rising Star
# 2
Rising Star
Hi M.C.,

I don't fully understand what you mean by "track clicks on multiple tags" but I believe that you can achieve this by creating Google AdWords conversions and changing the settings to track a conversion on a click instead of a page load: https://support.google.com/adwords/answer/6331304?hl=en

Jim


Jim Vaillancourt, AdWords Rising Star, LinkedIn
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: Tracking multiple conversions on the same html page

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Jim,

Thank you for your answer.

Sorry if my post wasn't clear: I'm already tracking conversion on click instead of on page load. If I have only one element to track on the page (say a <button> tag or a <a> tag) as a conversion everything works fine. The issue arises on pages where I have several elements that I want to track as different conversions, for instance, a page on which I have both a <button> labeled "Book Now" and also a <button> labeled "Add to cart". I would like to be able to count clicks on both buttons as conversions and also to get the breakdown of the number of conversions between the two buttons.

I hope that the question is now clearer.

Maybe I have to use the Adwords API in order to do that ?

Best,

M.C.

Re: Tracking multiple conversions on the same html page

Top Contributor
# 4
Top Contributor
Hi Maurizio C,

Looks like you can create 2 conversions. The only thing that changes is the value of w.google_conversion_label. Create just one set of the code defining the variables. Then, in the tag, first assign the proper value for w.google_conversion_label, then call goog_report_conversion(),

I'm looking at this page: https://support.google.com/adwords/answer/6331304?hl=en

Follow those instructions, make sure you have the correct value for w.google_conversion_id in the snippet. The example for a link shows:

<a onclick="goog_report_conversion ('http://example.com/your-link')"
href="http://example.com/your-link">Download now!</a>

Let's say the snippet assigns w.google_conversion_label = "abcDeFGHIJklmN0PQ"; and you want google_conversion_label to be "DeFGHIjklMnopqUVS". Do something like this:

<a onclick="w.google_conversion_label = 'DeFGHIjklMnopqUVS';goog_report_conversion ('http://example.com/your-link')"
href="http://example.com/your-link">Download now!</a>


Alternatively, you could create a js function that accepts 2 parameters: conversion_label and URL, the function would assign the proper conversion label, then pass the URL to goog_report_conversion().

function reportConversion(lConversion_label, lUrl) {
w.google_conversion_label = lConversion_label;
goog_report_conversion (lURL);
}

Now the link looks like this:

<a onclick="reportConversion( 'DeFGHIjklMnopqUVS', 'http://example.com/your-link')"
href="http://example.com/your-link">Download now!</a>

It also seems to me you can use the href of the link itself:

<a onclick="reportConversion( 'DeFGHIjklMnopqUVS', this.href)"
href="http://example.com/your-link">Download now!</a>

This works for the button example:
<button onclick="reportConversion( 'DeFGHIjklMnopqUVS',this.href);" href="http://example.com/your-link">Download now!</button>

This (this.href) won't work with the img example. You'll have to provide a literal string for the lURL.

Best of Luck!

Pete
petebardo -- Deadhead doing AdWords

Re: Tracking multiple conversions on the same html page

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Hi Pete,

Thank you very much for your answer.

I didn't know that you could have the w.google_conversion_label on buttons but it makes a lot of sense Smiley Happy !

I'll try it out and if it works I'll Accept your solution.

Thanks again,

M.C.

Re: Tracking multiple conversions on the same html page

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Hi Pete,

I've tried to implement your first solution. However, I wasn't successful in it Smiley Sad ...

I have put two conversion js snippets at the end of my <body> each with its own w.google_conversion_label and the same w.google_conversion_id. I then added the w.google_conversion_label in the onclick attribute of a <button> tag and of an <a> tag in the following way:

<button onclick="w.google_conversion_label='value from js snippet 1';goog_report_conversion('https://example.com/example.php')" href="https://example.com/example.php" type="submit">Add to cart</button>

<a onclick="w.google_conversion_label='value from js snippet 2';goog_report_conversion('https://example.com/example.php')" href="https://example.com/example.php">Buy now</a>

Then I've checked the results using the Google Tag Assistant. The <button> works correctly but the <a> gives me the following error: No HTTP response detected.

Any idea why this might happen ?

Thanks in advance,

M.C.