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

Dynamic Conversion Tracking Value

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm struggling to pull in the currency and value form orders dynamically for my Adwords conversion page.

 

On the confirmation page (order successful) I have the following generated for the dynamic variables:

 

<script>
dataLayer = [{ 'orderID': '801279', 'google_conversion_value':'297', 'google_conversion_currency': 'USD' }];

</script>

 

How do i now pass those values into the Adwords conversion script which is also placed on the same page?


Should it be with quotes:

var google_conversion_value = "google_conversion_value";
var google_conversion_currency = "google_conversion_currency";

 

Or (no quotes around variable)

 

var google_conversion_value = google_conversion_value;
var google_conversion_currency = google_conversion_currency;

 

Or should it be

var google_conversion_value = "<%google_conversion_value%>";
var google_conversion_currency = "<%google_conversion_currency%>";

 

Or should it be something completely different?

1 Expert replyverified_user

Re: Dynamic Conversion Tracking Value

Top Contributor
# 2
Top Contributor
Hi Chris S,

Turns out none of those will work! Ok, assuming you have only one dataLayer defined and that all this is Javascript and is all on the same page:

var google_conversion_value = dataLayer[0].google_conversion_value;
var google_conversion_currency = dataLayer[0].google_conversion_currency;

I tested this with Firebug, it should solve your problem.

Best of Luck!

Pete

petebardo -- Deadhead doing AdWords

Re: Dynamic Conversion Tracking Value

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks Pete; I'll give that a go!

Beyond that, the beginning of the second part of the conversion tracking code which is an IMG contains the following (where xxx should also be dynamic variables):

<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/990720859/?value=XXX&amp;currency_code=XXX

Should this be updated to the following or a different dynamic variable again?

<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/990720859/?value=dataLayer[0].google_conversion_value&amp...

Re: Dynamic Conversion Tracking Value

Top Contributor
# 4
Top Contributor
Hi Chris S,

No, that won't work. Javascript is not interpreted within the src attribute of the image tag. In this case, it's best to replace the xxx with the actual values with your server side script before returning the content.

Pete
petebardo -- Deadhead doing AdWords