News:

Support the VirtueMart project and become a member

Main Menu

Google Adwords Conversion Tracking

Started by jaderotheram, June 28, 2013, 17:38:01 PM

Previous topic - Next topic

oviliz


ITechnoDev

Quote from: oviliz on July 14, 2014, 12:24:08 PM
Gi Peter, can you please provide more details?

I made added the AdWords code at the end of my:
components/com_virtuemart/views/cart/tmpl/order_done.php
and
components\com_virtuemart\views\pluginresponse\tmp l\default.php

From the AdWords code, specific to my account, I changed only:
var google_conversion_value = 1.00;
with
var google_conversion_value = <?php echo $this->cart->pricesUnformatted['billTotal'] ?>;

I don't understand well the (same?) code about IMG src.

Anyway after that change the visitors confirmation orders are redirected to a blank cart/confirm.php page.

It means that there is a php error try to display the errors
Extensions for VirtueMart : http://www.itechnodev.com

ITechnoDev

Quote from: oviliz on July 14, 2014, 17:25:50 PM
In the end I solved with that plugin, virtuemartrackingextension.com

one page checkout component also have this feature
Extensions for VirtueMart : http://www.itechnodev.com

Peter Pillen

The code in the order-done file looks like this ... and this code needs to be placed in the different payment plugins that generate the "thank you for your order page". The google image url also needs part of the tracking code. It displays to the customer that google tracking is used. Depending per country you need to show this to the customers. If you don't need to show it - like me - give it a width and height of 1. In the code below the xxxxxxx stands for your google tracking id that is generated by google.

<?php

defined
('_JEXEC') or die('');

echo 
"<h3>".JText::_('COM_VIRTUEMART_CART_ORDERDONE_THANK_YOU')."</h3>";
echo 
"<p>".JText::_('COM_VIRTUEMART_CART_ORDERDONE_NOTICE')."</p>";
echo 
$this->html;

?>

<!-- Google Code for verkoop Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
//enter your id number instead of the xxxxxx
var google_conversion_id = xxxxxxxxxx;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "Ze5ZCPmL-gcQ94LN3gM";
var google_conversion_value = <?php echo $this->cart->pricesUnformatted['billTotal'?>;
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/xxxxxxxxxxxx/?value=<?php echo $this->cart->pricesUnformatted['billTotal'?>&amp;label=Ze5ZCPmL-gcQ94LN3gM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

escozul

There are people who insist that the google tracking code needs to be placed before the echo $this->html; part of the original order_done.php

I guess that the code would become as so:

<?php
defined
('_JEXEC') or die('');
?>

<div class="order">
<?php
echo "<h3>".JText::_('COM_VIRTUEMART_CART_ORDERDONE_THANK_YOU')."</h3>";

echo 
'<!-- Google Code for Order Conversion Page -->
    <script type="text/javascript">
    /* <![CDATA[ */
    var google_conversion_id = xxxxxxxxxxxx;
    var google_conversion_language = "el";
    var google_conversion_format = "3";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "sqf7COeAtggQkeiqxgM";
    var google_conversion_value = $this->cart->pricesUnformatted["billTotal"];
    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/xxxxxxxxxxxx/?value=$this->cart->pricesUnformatted["billTotal"]&amp;label=sqf7COeAtggQkeiqxgM&amp;guid=ON&amp;script=0"/>
    </div>
    </noscript>'
;

echo 
$this->html;
?>

</div>;


Would that work? Is that maybe the better way to go?

GJC Web Design

can't see it would make the slightest difference
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Danke

Hi all

Thank you for all your posts. Unfortunatelly it's not working for me. I use virtuemart 2.6.6

I've puttet the code like you descripted in:
/components/com_virtuemart/views/cart/tmpl/order_done.php

If i watch at the source of the confirmation page i can't see the tracking code. So it looks like I'm on the false file. But I can't find any other order_done.php.

Quote from logobis:
QuoteI'm user of Google ADWORDS and I confirm that the code should be implement in order_done.php (templates/YOUR_TEMPLATE/html/com_virtuemart/cart/order_done.php). IN my case, it's works perfectly even with 4 kinds of payments-> Paypal, Credit Card (ATOS), Check and Bank Transfer.
I use in virtuemart configuration -> templates -> shopfront settings -> "use joomla default"
But in the default template, i don't have a com_virtuemart folder, it's not existing. Neighter in one of the other templates.

Can anyone help me?

Thank you

Rune Rasmussen

I've looked into this on VM 2.6.x and it's not working with t.ex "standard" payment module, as it's emptying the cart BEFORE the confirm page is shown.

Line 146 in /plugins/vmpayment/standard/standard.php: $cart->emptyCart ();

Thus $this->cart->pricesUnformatted['billTotal'] will display nothing, as it's empty.

We could comment line 146, but that's probably not a very good idea. Anyone having a better?
Maybe devs could consider to empty the cart later in the process, at the end of the confirmation page, instead of in each payment module?
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

alatak

Hello

For the virtue mart piwik plugin, i wrote a system plugin with this event plgVmConfirmedOrder . It should work for Google Adwords also.

Rune Rasmussen

That's fine, but most people will not be able to do that. And a cart without Google Analytics and Adwords Conversion Tracking is not a "complete" cart.

Btw! From my point of view it seems weird to relay on the payment plugins to empty the cart, that's not very common for a cart system as far as I have seen.

It would be easy to move it I guess. And then add support for adding tracking codes in config, which is inserted to  components/com_virtuemart/views/cart/tmpl/order_done.php and components/com_virtuemart/views/pluginresponse/tmpl/default.php
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

Robert_ITMan

I have the following code that works for my VM 2.6 sites in template cart/order_done.php where the above suggested value from the cart doesn't work (because the cart is already cleared?) so I simply get the info directly from the database for the user as follows:


// begin Google AdWords Conversion added as per https://support.google.com/adwords/answer/6095947
// enter your values
$conversion_id = "1234567890"; // enter your conversion_id
$conversion_label = "abcDefghiJKLmnopqRS"; // enter your conversion_label
$currency = 'CAD'; // enter your currency - or get that from database too
// get this user
$user = JFactory::getUser();
$user_id=$user->id;
// get this order_id,order_total,order_status 
JFactory::getDBO()->setQuery("SELECT virtuemart_order_id,order_total,order_status FROM jos_virtuemart_orders WHERE virtuemart_user_id=$user_id ORDER BY virtuemart_order_id DESC LIMIT 1");
$this_order =JFactory::getDBO()->loadObjectList();
$this_order_id = $this_order[0]->virtuemart_order_id;
$this_order_total = number_format($this_order[0]->order_total, 2, '.', '');
$this_order_status = $this_order[0]->order_status;
//echo '<br />order id '.$this_order_id.' total $'.$this_order_total.' status '.$this_order_status;
if ($this_order_status == 'P' ) {
echo '<h2 style="color:#990000">!!! Sorry your payment did not process, if this is the first time this has happened to you please create a new order and make sure your payment information is correct before confirming it - if it fails again then please visit us or call us during office hours and we will be happy to help.</h2>';
}
echo '
<!-- Google Code for Order Done Conversion Page started 2015-07-21 -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = '.$conversion_id.';
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "'.$conversion_label.'";
var google_conversion_value = '.$this_order_total.';
var google_conversion_currency = "'.$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/'.$conversion_id.'/?value='.$this_order_total.'&amp;conversion_currency='.$currency.'&amp;label='.$conversion_label.'&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
<!-- end of Google Code for Order Done Conversion Page started 2015-07-21 -->
';
// end Google AdWords Conversion




WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

Rune Rasmussen

Note! Google Adwords has been rebranded into Google Ads recently (July 2018).

I'll recommend the new 'BIT Google Ads for Virtuemart' plugin released by BARG IT: https://barg-it.de/en/online-shop/extensions-joomla-3/bit-google-ads-for-virtuemart.html

It works great, also with special checkout and payment modules like One Page Checkout and Klarna Checkout, like the rest of their also recommended tracking extensions (FB Pixels, G Analytics etc.): https://barg-it.de/en/online-shop/extensions-joomla-3/bit-virtuemart-tracking-paket.html
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team