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

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I completed the conversion tracking wizard and at the end was given some JavaScript to paste to my page. Here is a snippet from the JavaScript:

 

var google_conversion_value = 0;

if (55) {

       google_conversion_value = 55;

 

If don't understand why the "if(55)" is in there. i.e. the initial assignment to 0 and then the conditional if statement look redundant to me. Ideas?

2 Expert replyverified_user

Hi _adwords_user,   The value you are referring to here i...

Top Contributor
# 2
Top Contributor

Hi _adwords_user,

 

The value you are referring to here is the conversion value which you have assigned manually while creating the Google Adwords conversion tracking code so as to see which conversions are more important than the others if you have set.

 

You can edit that value and may or may not assign anything as per your convenience. This is just a guideline to see what conversions are important in terms of ROI.

 

Hope this helps!

Pankaj

Hi pankaj,   Thank you for your reply. I understand its u...

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi pankaj,

 

Thank you for your reply. I understand its use and how it got there. What I'm trying to understand is why there is seemingly redundant code in there. For example, the if(55) will always be evaluated to true so why put it there? Why not assign the value to 55 at the beginning (where it is currently assigned 0) and ignore the if statement altogether.

 

Thanks

Hi _adwords_user,   Honestly I am not tech savvy :) but w...

Top Contributor
# 4
Top Contributor

Hi _adwords_user,

 

Honestly I am not tech savvy Smiley Happy but what I can say on your query is that there must be excellent programmers sitting in Adwords team who would have been working continuously over the Adwords conversion tracking script, the loops, the validations etc...So, they might think about the logic that way. Isn't it...

 

Thanks!

Pankaj

Hi _adwords_user,   That piece of the code isn't really n...

Top Contributor
# 5
Top Contributor

Hi _adwords_user,

 

That piece of the code isn't really necessary. You could just assign the value ont he first occurance of the google_conversion_value. I use the Google supplied version of the code. Where the 55 is, I substitute the actual value of the sale. What this piece of code says is "if the supplied value is greater than 0, assign the new value". If the supplied value is blank, or a space, or a string, this piece of code will break. To prevent that, I place the value in quotes. My cart uses << and >> to delimit variables in the script. It ends up looking like this:

 

var google_conversion_value = 0;

if ('<<totalSale>>') {

       google_conversion_value = '<<totalSale>>';

}

 

I hope this helps. Best of Luck!

 

Pete

 

petebardo -- Deadhead doing AdWords

Re: Conversion tracking JavaScript

Follower ✭ ✭ ✭
# 6
Follower ✭ ✭ ✭
Thank you, this is really helpful