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 for Woocommerce wordpress sites

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Going insane trying to set this up.

 

I think i'm right in saying that you use this variable to get the total cost from a Woocommerce thank you page:

 

<?php echo $woocommerce->cart->get_cart_total() ?>

 

So i've modified the code Google Adwords gave me like this:

 

<!-- Google Code for Google Adwords Purchase Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxxxxxxxxx - taken out;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "LwTpCKnIzV4QrI-ayAM";
if (<?php echo $woocommerce->cart->get_cart_total() ?>) {
var google_conversion_value = <?php echo $woocommerce->cart->get_cart_total() ?>
var google_conversion_currency = <? echo $currency ?>
}
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/xxxxxxx/?value=<?php echo $woocommerce->cart->get_cart_total() ?>&conversion_currency=<? echo $currency ?>&amp;label=LwTpCKnIzV4QrI-ayAM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

 

But still getting these errors:

 

 

Can anyone give any insight into this before I blow my mind out?

 

Thanks!

 

 

1 Expert replyverified_user

Re: Dynamic conversion tracking for Woocommerce wordpress sites

[ Edited ]
Rising Star
# 2
Rising Star

Hi Thomas, how are things?

 

I'm not a programmer myself, but I think the problem is that you're using the function 'echo' inside the quotation marks of src="", which is causing the 'echo' to be a TEXT, and not a function.

 

For me, I'd say you need to do some sort of text concatenation, something like:

URL part1 + woocommerce string + url part 2.

 

As the remarketing code is already part if a <javascript>  tag, I'd try something using plus signs (+) to concatenate pieces, like this:

 

src="//www.googleadservices.com/pagead/conversion/xxxxxxx/?value=" + <?php echo $woocommerce->cart->get_cart_total() ?> + "&conversion_currency=" + <? echo $currency ?> + "&amp;label=LwTpCKnIzV4QrI-ayAM&amp;guid=ON&amp;script=0"/>"

 

Notice that diving the URL into pieces and declaring them as text blocks wrapped up with quotation "", you let the php echo to be a function and not a text.

 

Although I'm not certain about that, this would be my guess Smiley Very Happy


Leandro Martinez | Basta1Click

Re: Dynamic conversion tracking for Woocommerce wordpress sites

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Leandrofm,

Thanks for taking the time to help! I'll check out what you've suggested and get back to you!

All the best

Re: Dynamic conversion tracking for Woocommerce wordpress sites

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
You cannot place a PHP code inside of the wordpress pages.
You need to use a plugin to track your conversions.

Re: Dynamic conversion tracking for Woocommerce wordpress sites

[ Edited ]
Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi Thomas, Did you ever get this figured out. Please let me know what you did if so. I've spent hours on this! Ahhh!

Re: Dynamic conversion tracking for Woocommerce wordpress sites

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Ah, I think I see the problem. Try changing each instance of '<?php echo' to just '<? echo'

This is what google recommends here: https://support.google.com/adwords/answer/6095947?hl=en&authuser=1

Re: Dynamic conversion tracking for Woocommerce wordpress sites

Explorer ✭ ✭ ☆
# 7
Explorer ✭ ✭ ☆
Hi Thomas

We got this plugin for tracking the value in a WooCommerce shop: https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/

Also have a look at this plugin: https://wordpress.org/plugins/woocommerce-google-dynamic-retargeting-tag/

Regards

Re: Dynamic conversion tracking for Woocommerce wordpress sites

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭
Hi Thomas!! I have exactly the same problem than you. I have spend two working days on it and im blowing my mind out too.... ¿Do you have your problem solved? It's too easy to set it if the prices are always the same... but with the specific prices... OMG. I would love if you could be able to fix that problem..... THANKS!!!!!!