VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: ScottKR24 on July 05, 2012, 14:33:16 PM

Title: Need to add google tracking code to....
Post by: ScottKR24 on July 05, 2012, 14:33:16 PM
I need to add google tracking code in the head tag of either the thank you page or the order confirmation page. I've downloaded the com_virtualmart folder from the server but there's so many files to look thru I'm not even sure where to look or what to look for. Please help, thanks.
Title: Re: Need to add google tracking code to....
Post by: ivus on July 18, 2012, 16:30:33 PM
Hi ScottKR24,

you can put it on this page

/components/com_virtuemart/views/cart/tmpl/order_done.php

This page appears once the order has been placed successfully.

I hope this helps.
Title: Re: Need to add google tracking code to....
Post by: KarlRanseier on August 13, 2012, 12:52:13 PM
yes the order_done.php is the right place for the tracking code but there is not much information about the bought products.
I have just few info about the shipping method, paymentmethod, and the total prices and taxes.
Would be nice to know how to get product information for this order...

Google tracking code:
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_addTrans',
    '1234',           // order ID - required
    'Acme Clothing',  // affiliation or store name
    '11.99',          // total - required
    '1.29',           // tax
    '5',              // shipping
    'San Jose',       // city
    'California',     // state or province
    'USA'             // country
  ]);

   // add item might be called for every item in the shopping cart
   // where your ecommerce engine loops through each item in the cart and
   // prints out _addItem for each
  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'DD44',           // SKU/code - required
    'T-Shirt',        // product name
    'Green Medium',   // category or variation
    '11.99',          // unit price - required
    '1'               // quantity - required
  ]);
  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
Title: Re: Need to add google tracking code to....
Post by: ivus on August 14, 2012, 02:52:40 AM
Hi KarlRanseier,

You should still have the order id when you're on that page. Why not write a query to grab the products from the order. I think the code is already written, you just need to target it.

I hope this helps.  ;D
Title: Re: Need to add google tracking code to....
Post by: berghoff on August 16, 2012, 13:39:47 PM
Please tell me how to get the order id inside order_done file.

Thank you.
Title: Re: Need to add google tracking code to....
Post by: Florentp on August 17, 2012, 17:01:10 PM
Quote from: berghoff on August 16, 2012, 13:39:47 PM
Please tell me how to get the order id inside order_done file.

Thank you.

Hey Berghoff !
If you can wait 24-48h, I'll tell you how to do.
I have to implement some custom functions in this page tomorrow for my own project.
Once I know more, I explain how.


ivus, thanks for this information
Can we be sure that this page is the good one ?
I mean.. What if customer pay on the bank website and never get back to the store !?
Title: Re: Need to add google tracking code to....
Post by: berghoff on August 25, 2012, 09:09:02 AM
After the payment is processed on the bank-side. Notification can be sent back to your site with POST.

This page is the best if you want to do the same operation for all payment types.

Waiting for your notes FederA.
Title: Re: Need to add google tracking code to....
Post by: Florentp on August 25, 2012, 15:48:14 PM
Hum, sorry men, finally i did something else.
Title: Re: Need to add google tracking code to....
Post by: PRO on August 25, 2012, 16:13:44 PM
I just use the url

cart/confirm

Title: Re: Need to add google tracking code to....
Post by: enspyre on March 15, 2013, 07:39:22 AM
Exactly HOW do I put the Adwords Javascript into "order_done.php"?

I guess I can't just past it in the end since that creates an error. I would very much appreciate a sample page.

Thanks,
Elias
Title: Re: Need to add google tracking code to....
Post by: PRO on March 15, 2013, 18:32:26 PM
whats the code first of all?

You probably are just not doing it right.

Title: Re: Need to add google tracking code to....
Post by: romatvirtue on September 07, 2013, 23:29:32 PM
Hi there. I have the same question. Although, my code is a facebook conversion tracking which should work the same way. I know that the best way to implement it in the order confirmation page. My problem is how do I properly insert the code?

I have currently implemented like this:

echo '<script type="javascript">
some variables...
</script>
<script language="javascript" src="https://www.facebook.com/xxxxxxxxxtracker.js">';


However, nothing is being captured.

Please help.

Thank you in advance.
Title: Re: Need to add google tracking code to....
Post by: romatvirtue on September 09, 2013, 05:14:48 AM
I have actually inserted the code like this:
Quote from: PRO on March 15, 2013, 18:32:26 PM
whats the code first of all?

You probably are just not doing it right.


I have actually inserted the code like this:

echo '<script type="javascript">
var a =  "123";
var b =  "456";
var c =  "789";
</script>
<script language="javascript" src="https://www.facebook.com/xxxxxxxxxtracker.js">';


Even though, their syntax is like this:
echo '<script type="javascript">
var a =  '123';
var b =  '456';
var c =  '789';
</script>
<script language="javascript" src="https://www.facebook.com/xxxxxxxxxtracker.js">';


I might not have written it properly. That's the only way it's not giving me an error. Also, how would I insert another similar tracking code? Your help will be greatly appreciated.

Thanks.
Title: Re: Need to add google tracking code to....
Post by: Maxim Pishnyak on September 15, 2013, 13:12:53 PM
So did you try to insert this code or you did not?
Title: Re: Need to add google tracking code to....
Post by: romatvirtue on September 16, 2013, 04:45:52 AM
Quote from: Maxim Pishnyak on September 15, 2013, 13:12:53 PM
So did you try to insert this code or you did not?

I did. However, nothing was tracking. So I thought I did something wrong, that's why I posted a question. Did I properly insert the code? The echo, single quotes and stuff...

Thanks.
Title: Re: Need to add google tracking code to....
Post by: Maxim Pishnyak on September 16, 2013, 04:48:26 AM
I need url to your web site and url to the page from where you got tracking codes.
Title: Re: Need to add google tracking code to....
Post by: romatvirtue on September 16, 2013, 06:30:41 AM
Quote from: Maxim Pishnyak on September 16, 2013, 04:48:26 AM
I need url to your web site and url to the page from where you got tracking codes.

Max, I replied you in the other post. Here's the URL to the other post for anybody having similar issue: http://forum.virtuemart.net/index.php?topic=116788.0

I am sorry for having this issue discussed in two different posts. I did not initially start either of them; I was just replying with my own questions.

Thanks.
Title: Re: Need to add google tracking code to....
Post by: Maxim Pishnyak on September 18, 2013, 10:13:58 AM
Quote from: romatvirtue on September 07, 2013, 23:29:32 PM
I have currently implemented like this:
Did you try to use
?>
...your code here...
<?php

?
Title: Re: Need to add google tracking code to....
Post by: romatvirtue on September 18, 2013, 22:44:59 PM
Quote from: Maxim Pishnyak on September 18, 2013, 10:13:58 AM
Quote from: romatvirtue on September 07, 2013, 23:29:32 PM
I have currently implemented like this:
Did you try to use
?>
...your code here...
<?php

?

Max, that's exactly how I did it. Did you get a chance to go through the checkout?
Title: Re: Need to add google tracking code to....
Post by: Maxim Pishnyak on September 19, 2013, 21:57:10 PM
Quote from: romatvirtue on September 18, 2013, 22:44:59 PM
Did you get a chance to go through the checkout?
Could you pm me a tips how I could do this?