Author Topic: Is there a working Google Analytics/Virtuemart  (Read 32702 times)

d3vlabs

  • Beginner
  • *
  • Posts: 21
Is there a working Google Analytics/Virtuemart
« on: July 02, 2009, 18:11:56 pm »
like the subject says.....


if not what are my alternatives?

d3vlabs

  • Beginner
  • *
  • Posts: 21
Re: Is there a working Google Analytics/Virtuemart
« Reply #1 on: July 02, 2009, 18:22:54 pm »
are there any additional modifications needs to be done to have it work with virtuemart? there are modules for analytics/virtuemart integration specifically im just not sure if any of them are working anymore with vm 1.1.3

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10270
  • VirtueMart Version: 3+
Re: Is there a working Google Analytics/Virtuemart
« Reply #2 on: July 02, 2009, 18:32:53 pm »
NO, your index file is your whole site. Just put the code in your index.php file

There is security risk added with every extension you add to your site. There is no need to add an extension for such a small task
I do NOT do development work for hire.

volksman3

  • Jr. Member
  • **
  • Posts: 91
    • Akira Studio
Re: Is there a working Google Analytics/Virtuemart
« Reply #3 on: November 27, 2009, 20:54:31 pm »
Would you be able to clarify that by adding the Google Analytics code to index.php that it will track the ecommerce side of the site in details and record total revenue etc (see screen shot)?

[attachment cleanup by admin]
Parachutes are like minds, they only work when they are open!
http://www.akirastudio.co.uk

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10270
  • VirtueMart Version: 3+
Re: Is there a working Google Analytics/Virtuemart
« Reply #4 on: November 27, 2009, 21:21:59 pm »
actually no it will not,
I do NOT do development work for hire.

volksman3

  • Jr. Member
  • **
  • Posts: 91
    • Akira Studio
Re: Is there a working Google Analytics/Virtuemart
« Reply #5 on: November 27, 2009, 21:49:53 pm »
Thanks for the reply, i am currently working with http://www.joomlaxtc.com/index.php?page=shop.product_details&flypage=flypage_new.tpl&product_id=31&category_id=2&option=com_virtuemart&Itemid=70 but so far no joy on reporting the ecommerce stats (even though it says it does and has a featire for it). I think the issue is that the store returns the user to the index page of the site  instead of checkout.thankyou, this is the case with all of my stores regardless of using SEF of not and i cant find the page checkout.thankyou so all very odd. I have put in a support ticket and if i get a working solution will post here unless you have any ideas on this issue?
Parachutes are like minds, they only work when they are open!
http://www.akirastudio.co.uk

mronayne

  • Beginner
  • *
  • Posts: 45
Re: Is there a working Google Analytics/Virtuemart
« Reply #6 on: February 21, 2010, 20:34:41 pm »
Yes, there is a working Google Analytics/Virtuemart.

I hope this response is in the right place. I spent a couple of days researching how to take advantage of Google Analytics Goal Conversion tracking through the Virtuemart checkout process and I have found a solution that works for me. I am hoping it works for others?

First let me thank the dozens of posts across various topics associated with Joomle/Virtuemart and Google Analytics. No single post gave me the complete answers I needed but by piecing together advice and recommendations for a number of posts I was able to come up with something that works.

I am using Joomla 1.5.15 with the RocketTheme Mynxx template designed for Virtuemart, and Virtuemart 1.1.3 stable.

Step 1: Get Google Analytics working with your Joomla installation. Sign up for Google Analytics and go through their process for acquiring your unique tracking code. If you don't know how to do this go to: http://www.google.com/support/googleanalytics/bin/answer.py?answer=66983&cbid=1p8mooumxqh3h&src=cb&lev=index and follow their directions.

Once you have your site registered and have acquired your tracking code you need to install it in your Joomla Template. This is a step that is specific to the template you are using with Joomla/Virtuemart. Since I am using Mynxx this example will also - you will need to map these instrustions to your specific template.

In your Joomla installation locate and open the file templates/rt_mynxx_j15/index.php.

Add your tracking code to the end of the index.php file just before the </body> tag. Example (Note: The comments in the code are mine):
Code: [Select]
<!-- BEGIN Google Analytics Code Part 1 -->
<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<!-- END Google Analytics Code Part 1 -->
<!-- BEGIN Google Analytics Code Part 2 -->
<script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-nnnnnnnn-1");
    pageTracker._trackPageview();
    } catch(err) {}
</script>
<!-- END Google Analytics Code Part 2 -->

Upload your updated index.php file and you should now have the basic Google Analytics tracking setup properly. Keep in mind it can take Google a few hours to validate that tracking code is installed correctly so you may have to wait.

Once you are comfortable that the basic Google Analytics tracking code is working properly (after a day or two of tracking site visits) then you can move on to the next step - Adding Goal Conversion tracking.

Step 2:

You are going to have to edit a few Virtuemart files in this next section - Please - make backup copies of each of the files mentioned before editing them. It's always good practice.

This article from Google is a good reference for what is about to be explained next: http://www.google.com/support/googleanalytics/bin/answer.py?answer=55576 It will outline how to create "virtual" URLs to be used specifically for tracking Goal Conversions and the associated Goal "funnel".

Step 2-A. Move the first Google Analytics Script file to the <head> section of your index.php file. You want the first part of the script to be loaded first on the page.
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language?>" lang="<?php echo $this->language?>" >
<head>
    <!-- BEGIN Google Analytics Code Part 1 -->
    <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <!-- END Google Analytics Code Part 1 -->

Leave the second part of the Google Analytics script where it is - just before the </body> tag. Note: this isn’t normally recommended by Google since if there is a problem loading the GA script from Google your site may display slowly or not at all but to date I haven’t had a problem – just be aware if you start experiencing performance or page load errors.

Step 2-B: Locate and open the file: administrator/components/com_virtuemart/html/checkout.thankyou.php. This is the php that executes to display the successful "Thank you for ordering" VM page.

At the end of this file, just before the closing php tag "?>" place the following code:
Code: [Select]
echo '<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-nnnnnnnn-1");
pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");
} catch(err) {}
    </script>';

It is a slightly modified "2nd part GA Script". Note that "var pageTracker" is changed to "pageTracker_co" and the line after that is changed to "pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");"

Please take special note that this entire script string is output via "echo" at run time by the php script. If you simply paste in the GA tracking code without making it an echo'd string it won't work.

This creates a different instance of the GA tracker that will send GA a page hit on "/funnel_Cejay1/checkoutComplete.html". This is the page that is my target "Goal" URL. Refer to Google help for setting up your GA goals and funnels.

Step 3: Setting up a funnel.

Using the same approach we used in Step 2-B we are going to add similar GS tracking code to the following files: They are all located in:

components/com_virtuemart/themes/"YourTheme"/templates/checkout

Code: [Select]
get_shipping_address.tpl.php
get_shipping_method.tpl.php
get_payment_method.tpl.php
get_final_confirmation.tpl.php

These php scripts output a page for each of the checkout steps in VM - you know, the ones that all have the URL of index.php.

As with the checkout.thankyou.php modifications above you will edit each of these files and place a slightly modified GA script in each to output when the page loads. NOTE: In these files you do not need to use the "echo" function. You can simply paste the GA script.

Open and edit get_shipping_address.tpl.php placing the following at the end of the file.
Code: [Select]
<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-nnnnnnnn-1");
pageTracker_co._trackPageview("/funnel_Cejay1/getShippingAddress.html");
} catch(err) {}
</script>


What's important, and different, here is the virtual URL "/funnel_Cejay1/getShippingAddress.html"

You can actually call this anything you like as long as you use something different for each step. When this page is loaded it will send GA tracking the URL "/funnel_Cejay1/getShippingAddress.html". And this is the first step in our checkout process funnel.

I won't show each of the other three file modifications - they are virtually identical except for what you call the virtual URL.

That's it - at least I believe I covered all the necessary steps. If I had more time I would have done a more thorough step-by-step. I hope I didn't forget anything.

Feel free to contact me if you have any questions. I will try to help time permitting.

Thanks again to all that came before me, each adding their piece of this puzzle.

Mike

vickyb

  • Beginner
  • *
  • Posts: 5
Re: Is there a working Google Analytics/Virtuemart
« Reply #7 on: February 24, 2010, 14:15:56 pm »
Hi Mike,

You have posted very useful information.

I have followed above instructions to create Virtual URLs and I think you had covered every point about how to Add Google Analytics Code to track Virtue Mart Checkout pages.

Thanks Very much for such a useful information !!

Kind Regards,
vickyb

mapri

  • Beginner
  • *
  • Posts: 14
Re: Is there a working Google Analytics/Virtuemart
« Reply #8 on: March 11, 2010, 15:02:40 pm »
...long but awsome guide


To be sure, are you supposed to change the UA-nnnnnnnn-1 to your own code or wil google fetch it from your index.php?

mronayne

  • Beginner
  • *
  • Posts: 45
Re: Is there a working Google Analytics/Virtuemart
« Reply #9 on: March 11, 2010, 15:49:19 pm »
To be sure, are you supposed to change the UA-nnnnnnnn-1 to your own code or wil google fetch it from your index.php?

Yes, you need to use your specific Google Analytics code...

Bruce Morgan

  • Sr. Member
  • ****
  • Posts: 672
Re: Is there a working Google Analytics/Virtuemart
« Reply #10 on: March 11, 2010, 16:25:57 pm »
Wow, that is one long and complicated hack.  I think I was the first person to implement GA and conversion tracking four years ago and to share it with this forum.  It was all custom coding that I paid someone to do for me.  It was a pain in the neck to hack the files again with every VM update and I finally dumped the system I had when the Joomla XTC solution came out for a very modest price.  It works great and it easy to implement and you do not need to hack anything.  Most important it "survives" minor VM updates without a hiccup.

I commend the work you have done.  I think GA and conversion tracking is vitally important to any e-commerce web site.  Justr think it is important to point out ther are module ready to go that do not require hacking core files.

Bruce
www.pepper-passion.com

mapri

  • Beginner
  • *
  • Posts: 14
Re: Is there a working Google Analytics/Virtuemart
« Reply #11 on: March 26, 2010, 09:47:04 am »
It works for the first 3 stages but it doesn't seem to recognize the final "thankyou" page (step 2-B) i did exactly as discribed and placed the code just before the closing ?>. My checkoutComplete is somewhat modified by an iDeal payment module but since your mod just echos a script i don't see where it could go wrong?

If i paste the url (mysite.nl/funnel_Cejay1/checkoutComplete.html) directly in my browser google picks it up ok.

Code: [Select]
if (file_exists('phpcipher.bin')) return include('phpcipher.bin');
elseif (file_exists('../phpcipher.bin')) return include('../phpcipher.bin');
elseif (file_exists('../../phpcipher.bin')) return include('../../phpcipher.bin');
elseif (file_exists('../../../phpcipher.bin')) return include('../../../phpcipher.bin');
elseif (file_exists('../../../../phpcipher.bin')) return include('../../../../phpcipher.bin');
else print 'A required file <b>phpcipher.bin</b> was not found.';
echo '<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-xxxx-1");
pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");
} catch(err) {}
    </script>';
?>

mronayne

  • Beginner
  • *
  • Posts: 45
Re: Is there a working Google Analytics/Virtuemart
« Reply #12 on: March 28, 2010, 15:05:05 pm »
It works for the first 3 stages but it doesn't seem to recognize the final "thankyou" page (step 2-B) i did exactly as discribed and placed the code just before the closing ?>. My checkoutComplete is somewhat modified by an iDeal payment module but since your mod just echos a script i don't see where it could go wrong?

If i paste the url (mysite.nl/funnel_Cejay1/checkoutComplete.html) directly in my browser google picks it up ok.

Code: [Select]
if (file_exists('phpcipher.bin')) return include('phpcipher.bin');
elseif (file_exists('../phpcipher.bin')) return include('../phpcipher.bin');
elseif (file_exists('../../phpcipher.bin')) return include('../../phpcipher.bin');
elseif (file_exists('../../../phpcipher.bin')) return include('../../../phpcipher.bin');
elseif (file_exists('../../../../phpcipher.bin')) return include('../../../../phpcipher.bin');
else print 'A required file <b>phpcipher.bin</b> was not found.';
echo '<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-xxxx-1");
pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");
} catch(err) {}
    </script>';
?>


I assume in your actual code you replaced the "UA-xxxx-1" with your GA Assigned ID?

Also, the "/funnel_Cejay/" was used by me to uniquely ID my specific funnel - you can use this syntax if you choose but you can also specify your own as long as what you enter into your GA Funnel matches.

Other than those two observations, I don't see anything wrong with this piece of code...

mapri

  • Beginner
  • *
  • Posts: 14
Re: Is there a working Google Analytics/Virtuemart
« Reply #13 on: March 29, 2010, 09:33:51 am »
i use my own code for xxxx. Below i pasted the entire file (with some stuff blanked out)
Code: [Select]
<?php

$phpCipherLicenseFile
='license.lic';
$pce2ac3a591f68b51a9xxxxxxxx=__FILE__;
$phpCipher='cciDEAL 2.x, ontwikkeld door Chill Creations

cdOe8u=vAPXgoYl9xYrMQ=QLyfC7yVRXTEUqRMpbh75LCKs6JvTO3w4KRPkuK8luAXV2eV7Cc
TnNt7jt=dViAu+r/ENF/4zBDGZXB9TTc4n5wlkKKLb3K9KQ7M7GhUfMJsXOt12p1iOXEjGWD3
+o=WeeAsLGNq4GFSU3DsgwfCecVlBsAIndqnhznogcy5vHmkEyo1Kcgkr/j79F4Ph5YVj=J8I
t5SJ9RfKAKBZuOJ4HYWrs=PDB4KdcJ6jZ=+v6X+Xzpx74ev1m5cnd8BN2mzz=nAD6upEvpz0W 
......and about 200 more lines of scrambled code.......
JvzDRD8KsdJrDpD8cdDXCsJDrs'
;
//PHPCIPHER NO ENCRYPT
if (file_exists('phpcipher.bin')) return include('phpcipher.bin');
elseif (
file_exists('../phpcipher.bin')) return include('../phpcipher.bin'); 
elseif (
file_exists('../../phpcipher.bin')) return include('../../phpcipher.bin'); 
elseif (
file_exists('../../../phpcipher.bin')) return include('../../../phpcipher.bin'); 
elseif (
file_exists('../../../../phpcipher.bin')) return include('../../../../phpcipher.bin'); 
else print 
'A required file <b>phpcipher.bin</b> was not found.';
echo 
'<script type="text/javascript">
try {
var pageTracker_co = _gat._getTracker("UA-8xxxx-1");
pageTracker_co._trackPageview("/funnel_Cejay1/checkoutComplete.html");
} catch(err) {}
    </script>'
;
?>

mronayne

  • Beginner
  • *
  • Posts: 45
Re: Is there a working Google Analytics/Virtuemart
« Reply #14 on: March 29, 2010, 13:42:22 pm »
Just a thought... I am by no means a PHP expert but I noticed that when curly brackets are not used the ":" is added to an if/elsif block to terminate the if/elseif" condition statements in the PHP Manual? Could it be that your script isn't executing due to the echo statement being blocked because it's evaluated inside  the if/elseif block?
According to the PHP manual the following would be the proper syntax - note the ":"
Code: [Select]
if (file_exists('phpcipher.bin')): return include('phpcipher.bin');
elseif (file_exists('../phpcipher.bin')): return include('../phpcipher.bin');
elseif (file_exists('../../phpcipher.bin')): return include('../../phpcipher.bin');
elseif (file_exists('../../../phpcipher.bin')): return include('../../../phpcipher.bin');
elseif (file_exists('../../../../phpcipher.bin')): return include('../../../../phpcipher.bin');
else: print 'A required file <b>phpcipher.bin</b> was not found.';

If this doesn't work I also believe you can move the GA script outside the PHP block and eliminate the "echo" and just use a straight <script></script> block? I haven't tested it this way but I see no reason why this wouldn't work as well.