Author Topic: Virtuemart conversion tracking with Google Analytics - HOW??  (Read 40896 times)

cinos

  • Jr. Member
  • **
  • Posts: 85
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #15 on: March 19, 2009, 10:59:44 am »
Thanks for the help though.  :)

cinos

  • Jr. Member
  • **
  • Posts: 85
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #16 on: March 19, 2009, 11:17:52 am »
Unfortunately the debug idea did not work.

When I got to the Activation Complete page there was no debug window at the bottom and no information telling me which files were being used for the page.

Thanks anyway, are there any other ways that I can find out?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27478
  • Always on vacation
    • Jenkin Hill Internet
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #17 on: March 23, 2009, 12:08:57 pm »
Acivation by email is handled in Joomla's com_user component so that is the area you will need to look at. The "activated" text string is REG_ACTIVATE_COMPLETE which is called by components/com_user/controller.php so maybe the analytics code could be inserted there.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

cinos

  • Jr. Member
  • **
  • Posts: 85
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #18 on: March 23, 2009, 14:06:43 pm »
Cheers jenkinhill.

I tried putting the code in the obvious places but it seems that the google code just breaks everything in there. Ideally the code needs to be specifically in an area that handles the registration since I obviously don't want to be recording conversions for people who are just logging in.

With just a quick scan of how the code is laid out, it could be that I'm on to a lost cause here.

Thanks anyway though.  ;)

bemovi

  • Beginner
  • *
  • Posts: 1
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #19 on: March 30, 2009, 22:51:40 pm »
I'm trying to use the AdWords code in get_final_confirmation.tpl.php
I am redirecting buyers to PayPal so I assumed this would be the best place to insert the code instead of checkout.thankyou.tpl.php
Does this make any sense?
Where should I place the code in get_final_confirmation.tpl.php?
Thanks a bunch

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27478
  • Always on vacation
    • Jenkin Hill Internet
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #20 on: March 31, 2009, 00:04:08 am »
I'd put the code in the footer/debug position of the J! template and set final_confirmation as a goal in Analytics.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

samparker89

  • Jr. Member
  • **
  • Posts: 56
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #21 on: August 07, 2009, 10:46:49 am »
Hi All,

Just adding a piece of info to this forum that i feel may help. I have succesfully added the conversion code to my thankyou page with no problems by using an iframe. I just inserted this code after the closing php tag and it worked:

<iframe src="/google-cpc.htm" width="5" height="5"
frameborder="0" scrolling="no" name="Google"></iframe>

Obviously you will need to create a page with your google code in and link to it through iframe. I think inserting this iframe on any page would work.

I am just a beginner so if what i am saying is wrong then please feel free to tell me!

Cheers

Jason Farmer

  • Beginner
  • *
  • Posts: 49
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #22 on: March 12, 2010, 11:57:18 am »
I believe that whatever you do here will be a fudge and will be inaccurate unless you are taking payments on your site yourself.

Google Analytics needs to be in a page that is displayed to the customer (so the js can read the clients cookie etc) so using paypal ipn is a non starter.

Using paypal, sagepay forms etc , or cheques where customers are leaving your site to pay on another.

You have the choice of either
  • 1. Optimistic. All Transactions where final confirm button is clicked. Taking the transaction as completed and reporting it to google analytics when they click on that final confirm button before they leave your site to go to the payment site... perhaps the simplest to set up. bear in mind that this method may well significantly 'over report' as people abandon when they get to the payment site.
  • 2. Pessimistic. Only report transactions where payment is made and client returns to your site. hope that the client returns to your site after paying (you can put in extra prompts to help) then use the thankyou/order confirmation page to send data to google analytics - bear in mind that this will need setting up seperately for each payment method you use and may significantly 'under report' due to people paying and not returning to your site.

paypal return page is set in Virtuemart...Store...List payment methods...Paypal ... Configuration... extra payment info. mine is
Code: [Select]
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),edit: I'll come back to this as I work it out... :)

the relevant php file is found at /administrator/components/com_virtuemart/html/checkout.result.php

It already does a job in verifying that the order_id is valid and that the status is confirmed or pending(!) and says thankyou if all is kosher.

Paypal gives some sample PDT code that can be used here...
Code: [Select]
<?php
// read the post from PayPal system and add 'cmd'
$req 'cmd=_notify-synch';

$tx_token $_GET['tx'];
$auth_token "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " strlen($req) . "\r\n\r\n";
$fp fsockopen ('www.paypal.com'80$errno$errstr30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp$header $req);
// read the body data
$res '';
$headerdone false;
while (!
feof($fp)) {
$line fgets ($fp1024);
if (
strcmp($line"\r\n") == 0) {
// read the header
$headerdone true;
}
else if (
$headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines explode("\n"$res);
$keyarray = array();
if (
strcmp ($lines[0], "SUCCESS") == 0) {
for (
$i=1$i<count($lines);$i++){
list(
$key,$val) = explode("="$lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname $keyarray['first_name'];
$lastname $keyarray['last_name'];
$itemname $keyarray['item_name'];
$amount $keyarray['payment_gross'];

echo (
"<p><h3>Thank you for your purchase!</h3></p>");

echo (
"<b>Payment Details</b><br>\n");
echo (
"<li>Name: $firstname $lastname</li>\n");
echo (
"<li>Item: $itemname</li>\n");
echo (
"<li>Amount: $amount</li>\n");
echo (
"");
}
else if (
strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}

}

fclose ($fp);

?>


Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br> You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br>

google analytics gives this code for tracking transactions...
Code: [Select]
<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>
<script type="text/javascript">
try{
  var pageTracker = _gat._getTracker("UA-xxxxx-x");
  pageTracker._trackPageview();
  pageTracker._addTrans(
      "1234", // order ID - required
      "Womens Apparel", // affiliation or store name
      "11.99", // total - required
      "1.29", // tax
      "15.00", // 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
   pageTracker._addItem(
      "1234", // order ID - necessary to associate item with transaction
      "DD44", // SKU/code - required
      "T-Shirt", // product name
      "Olive Medium", // category or variation
      "11.99", // unit price - required
      "1" // quantity - required
   );

   pageTracker._trackTrans(); //submits transaction to the Analytics servers
} catch(err) {}
</script>





DevelopmentProduction
VirtueMart  
2.0.12b
1.1.3
Joomla!  
2.5.6
1.5.14
Mysql 
5.5.8
5.0.51
PhP  
5.3.5
5.2.4

Jason Farmer

  • Beginner
  • *
  • Posts: 49
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #23 on: March 20, 2010, 23:25:56 pm »

This requires a new checkout.result.php (just about rewritten) in .../administrator/components/com_virtuemart/html
Code: [Select]
<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
* PayPal IPN Result Checker
*
* @version $Id: checkout.result.php 1394 2008-05-04 19:05:15Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );
global 
$db$vmLogger$VM_LANG;

function 
preg ($m) {
return '/{'.$m.'}/ix';
}
$valid=true;

if( !isset( 
$_REQUEST["order_id"] ) || empty( $_REQUEST["order_id"] )) {
echo $VM_LANG->_('VM_CHECKOUT_ORDERIDNOTSET');
$valid=false;
} else
{

// order_id is set - this is a paypal transaction...
// validate the order_id...
include( CLASSPATH"payment/ps_paypal.cfg.php" );
$values=array();
$values['order_id']= intvalvmGet$_REQUEST"order_id" ));
$values['user_id']=$auth["user_id"];

$sql =<<<HEREDOC
SELECT order_status,order_total,order_currency 
FROM #__{vm}_orders 
WHERE #__{vm}_orders.user_id={user_id}
AND #__{vm}_orders.order_id={order_id}
HEREDOC;

$sql=preg_replace(array_map("preg",array_keys($values)),array_map("mysql_escape_string",$values),$sql);
$db->query($sql);

if ($db->next_record()){
$values['order_status'] = $db->f("order_status");
if($values['order_status'] == PAYPAL_VERIFIED_STATUS || $values['order_status'] == PAYPAL_PENDING_STATUS) {
printf('         <img src="%simages/button_ok.png" align="middle" alt="%s" border="0" />',
VM_THEMEURL,$VM_LANG->_('VM_CHECKOUT_SUCCESS'));
printf(' <h2>%s</h2>',$VM_LANG->_('PHPSHOP_PAYPAL_THANKYOU'));

// echo('<pre> $_GET <br/>');
// print_r($_GET);
// echo("</pre>");


// check we've got PDT switched on...
if( !isset( $_GET['tx'] ) || empty( $_GET['tx'] )) {
//PDT is not switched on...
//Are we expecting it to be on?
if(PAYPAL_PDT_AUTH!=""){$vmLogger->err("Paypal Data Transfer unavailable.",false);$valid=false;}
} else
{
// PDT is switched on...
// read the post from PayPal system and add 'cmd'
$req 'cmd=_notify-synch';
$tx_token vmGet($_GET,'tx');

$req .= "&tx=$tx_token&at=".PAYPAL_PDT_AUTH;

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " strlen($req) . "\r\n\r\n";
$fp fsockopen (PAYPAL_URL80$errno$errstr30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
$vmLogger->err("Paypal Data Transfer Http error.",false);
$valid=false;
// HTTP ERROR
} else {
fputs ($fp$header $req);
// read the body data
$res '';
$headerdone false;
while (!feof($fp)) {
$line fgets ($fp1024);
if (strcmp($line"\r\n") == 0) {
// read the header
$headerdone true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines explode("\n"$res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1$i<count($lines);$i++){
list($key,$val) = explode("="$lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// echo('<pre> $keyarray <br/>');
// print_r($keyarray);
// echo("</pre>");

$fraud_state=false;
if (PAYPAL_EMAIL!=$keyarray['receiver_email']){$fraud_state=true;$vmLogger->err("Fraud? receiver_email corrupt : ".$values['txn_id']);}
if ($db->f("order_total")!=$keyarray['mc_gross']){$fraud_state=true;$vmLogger->err("Fraud? payment_amount corrupt : ".$values['txn_id']." ".$db->f("order_total")." != ".$keyarray['mc_gross']);}
if ($db->f("order_currency")!=$keyarray['mc_currency']){$fraud_state=true;$vmLogger->err("Fraud? payment_currency corrupt : ".$values['txn_id']." ".$db->f("order_currency")." != ".$keyarray['mc_currency']);}



//bung this lot into the database....
## 
## Table structure for table `#__{vm}_paypal`
## 

$db->query"CREATE TABLE IF NOT EXISTS `#__{vm}_paypal` (
  type char(3) NOT NULL,
txn_id char(20) NOT NULL,
txn_type char(39),
    created_date timestamp,
    payment_date timestamp,
    user_id int(11),
order_id int(11),
order_status char(1),
payment_status char(50),
mc_gross decimal(10,2),
mc_fee decimal(10,2),
    mc_currency char(3),
    tax decimal(10,2),
    shipping decimal(10,2),
    handling_amount decimal(10,2),
    payment_type char(30),
    payer_email char(127),
    protection_eligibility char(20),
    payer_status char(20),
    first_name char(64),
    last_name char(64),
    address_name char(128),
    address_status char(10),
    address_street char(200),
    address_city char(40),
    address_state char(40),
    address_zip char(20),
    address_country char(64),
    address_country_code char(2),
    payer_business_name char(127),
    pending_reason char(64),
    transaction_subject char(64),
    item_name char(64),
    item_number char(64),
    quantity int(11),
    residence_country char(64),
    business char(64),
    receiver_email char(127),
    receiver_id char(64),
    payer_id char(64),
    invoice char(64),
    charset char(64),
    custom char(64),
    payment_gross int(11),
    payment_fee int(11),

  PRIMARY KEY  (`txn_id`,created_date),
  KEY `idx_paypal_txn_id` (`txn_id`),
  KEY `idx_paypal_order_id` (`order_id`)
) TYPE=MyISAM COMMENT='Paypal transactions are stored here'; "
);

$sql_insert=<<<HEREDOC
INSERT INTO `#__{vm}_paypal`
(`type`,
`txn_id`,
`txn_type`,
`created_date`,
`payment_date`,
`user_id`,
`order_id`,
`order_status`,
`payment_status`,
`mc_gross`,
`mc_fee`,
`mc_currency`,
`tax`,
`shipping`,
`handling_amount`,
`payment_type`,
`payer_email`,
`protection_eligibility`,
`payer_status`,
`first_name`,
`last_name`,
`address_name`,
`address_status`,
`address_street`,
`address_city`,
`address_state`,
`address_zip`,
`address_country`,
`address_country_code`,
`payer_business_name`,
`pending_reason`,
`transaction_subject`,
`item_name`,
`item_number`,
`quantity`,
`residence_country`,
`business`,
`receiver_email`,
`receiver_id`,
`payer_id`,
`invoice`,
`charset`,
`custom`,
`payment_gross`,
`payment_fee`)
VALUES
(
"{type}",
"{txn_id}",
"{txn_type}",
current_timestamp,
"{payment_date}",
"{user_id}",
"{order_id}",
"{order_status}",
"{payment_status}",
"{mc_gross}",
"{mc_fee}",
"{mc_currency}",
"{tax}",
"{shipping}",
"{handling_amount}",
"{payment_type}",
"{payer_email}",
"{protection_eligibility}",
"{payer_status}",
"{first_name}",
"{last_name}",
"{address_name}",
"{address_status}",
"{address_street}",
"{address_city}",
"{address_state}",
"{address_zip}",
"{address_country}",
"{address_country_code}",
"{payer_business_name}",
"{pending_reason}",
"{transaction_subject}",
"{item_name}",
"{item_number}",
"{quantity}",
"{residence_country}",
"{business}",
"{receiver_email}",
"{receiver_id}",
"{payer_id}",
"{invoice}",
"{charset}",
"{custom}",
"{payment_gross}",
"{payment_fee}"
);
HEREDOC;

$sql_check=<<<HEREDOC
SELECT count(*) as check_count from #__{vm}_paypal 
WHERE type="PDT" AND txn_id ="{txn_id}";
HEREDOC;


$values=array_merge($values,$keyarray);
$values['payment_date']=strtotime($values['payment_date']);
$values['type']="PDT";
$sql=preg_replace(array_map("preg",array_keys($values)),array_map("mysql_escape_string",$values),$sql_insert);
$db->query($sql);

$sql=preg_replace(array_map("preg",array_keys($values)),array_map("mysql_escape_string",$values),$sql_check);
$db->query($sql);
$db->next_record();
if(intval($db->f("check_count"))<>1){
$fraud_state=true;
$vmLogger->err("Fraud? Same txn_id as a previous PDT transaction : ".$values['txn_id']);
}

if ($keyarray['payment_status']=="Completed"||$keyarray['payment_status']=="Pending"){
// Pending could be an echeck or any delayed transaction -- but this is our one chance to report it to google...
if ($fraud_state){
$valid=false;
}else{
// there is no need to update the order_status here as the IPN notify script will do that asynchronously and more reliably...
require_once( CLASSPATH"ps_google.php" );
ps_google::process_conversion$values['order_id'] );

}
}else{
$valid=false;
}
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
$vmLogger->err("PDT FAIL ".join("\r\n",$lines),false);
$valid=false;
}else {
$vmLogger->err("PDT unrecognised return ".join("\r\n",$lines),false);
$valid=false;
}
}
}
fclose ($fp);



} else {
$vmLogger->err("Paypal PDT not checked as Order Status corrupt? :".$db->f("order_status"),false);
$valid=false;
printf('         <img src="%simages/button_cancel.png" align="middle" alt="%s" border="0" />',
VM_THEMEURL,$VM_LANG->_('VM_CHECKOUT_FAILURE'));
printf(' <h2>%s</h2>',$VM_LANG->_('PHPSHOP_PAYPAL_ERROR'));
}

printf('<br /><p><a href="index.php?option=com_virtuemart&page=account.order_details&order_id=%s">%s</a></p>',
$values['order_id'], $VM_LANG->_('PHPSHOP_ORDER_LINK'));
} else {
$vmLogger->err("Order not found :"$values['order_id']. " for user ".$values["user_id"] . " ",false);
echo $VM_LANG->_('VM_CHECKOUT_ORDERNOTFOUND') . '!';
$valid=false;
}

If($valid){
$firstname $keyarray['first_name'];
$lastname $keyarray['last_name'];
$itemname $keyarray['item_name'];
$amount $keyarray['mc_gross'];

echo ("<h3>Thank you for your purchase!</h3>\n");

echo ("<b>Payment Details</b><br>\n");
echo ("<ul><li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li></ul>\n");
echo ("");
echo "Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br>";

}

echo "You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br>";
}
?>

which uses a new ps_google.php and ps_google.cfg.php and some new values in ps_paypal.cfg.php

new values in ps_paypal.cfg.php in .../administrator/components/com_virtuemart/classes/payment
Code: [Select]
define ('PAYPAL_URL', 'www.paypal.com'); // just to make it easier switching in and out of the sandbox...
// this token is available from Profile - Website Payment Preferences
define ('PAYPAL_PDT_AUTH',"5KK_UpU_qwertyuiopgfghjkfghjkjke_etc");


ps_google.cfg.php in .../administrator/components/com_virtuemart/classes
Code: [Select]
<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 

define ('GOOGLE_ID''UA-123456-1');

?>

ps_google.php in .../administrator/components/com_virtuemart/classes
Code: [Select]
<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
* Post conversion to google using ga.js
*
* @version $Id: ps_google.php 1394 2008-05-04 19:05:15Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

class ps_google {
function preg ($m) {return '/{'.$m.'}/ix';}
    function process_conversion($order_id) {
        global 
$VM_LANG$vmLogger;
        
/* init the database */
        
$google_db =& new ps_DB;
        include(
CLASSPATH."ps_google.cfg.php");
        
        
$valid true;
       
$google_order=<<<HEREDOC
       
       <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>
<script type="text/javascript">
try{
  var pageTracker = _gat._getTracker("{GOOGLE_ID}");
  
  pageTracker._addTrans(
      "{order_id}", // order ID - required
      "{vendor_name}", // affiliation or store name
      "{order_total}", // total - required
      "{order_tax}", // tax
      "{order_shipping}", // shipping
      "{city}", // city
      "{state}", // state or province
      "{country}" // country
    );
 
{google_lines}



   pageTracker._trackTrans(); //submits transaction to the Analytics servers
} catch(err) {}
</script>
HEREDOC;
$google_lines=array();
   
// 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 

   
$google_line=<<<HEREDOC

   pageTracker._addItem(
      "{order_id}", // order ID - necessary to associate item with transaction
      "{order_item_sku}", // SKU/code - required
      "{order_item_name}", // product name
      "{product_attribute}", // category or variation
      "{product_item_price}", // unit price - required
      "{product_quantity}" // quantity - required
   );
HEREDOC;


        
$sql_order =<<<HEREDOC
SELECT o.order_total,
o.order_tax,
o.order_shipping,
u.city,
u.state,
u.country,
(select vendor_name from #__{vm}_vendor v where v.vendor_id=o.vendor_id LIMIT 1) as vendor_name
FROM #__{vm}_orders o
LEFT OUTER JOIN  #__{vm}_order_user_info u
ON o.order_id=u.order_id
WHERE o.order_id="{order_id}";
HEREDOC;

           
$sql_lines =<<<HEREDOC
     SELECT
`#__{vm}_order_item`.`order_item_sku`,
`#__{vm}_order_item`.`order_item_name`,
`#__{vm}_order_item`.`product_quantity`,
`#__{vm}_order_item`.`product_item_price`,
`#__{vm}_order_item`.`product_attribute`
FROM `#__{vm}_order_item`
WHERE `#__{vm}_order_item`.`order_id` ="{order_id}"
ORDER BY `#__{vm}_order_item`.`order_item_id`;
HEREDOC;


        
$values=array();
        
$values['GOOGLE_ID']=GOOGLE_ID;
        
$values['order_id']=$order_id;
        
$config=$values;
        
$sql=preg_replace(array_map(array("ps_google","preg"),array_keys($values)),array_map("mysql_escape_string",$values),$sql_order);
$google_db->query($sql);
        if (!
$google_db->next_record()) {
$vmLogger->err"ORDER NOT FOUND :".$order_id );
$valid=false;
        }else{
        
$values=array_merge($values,(array) $google_db->getCurrentRow());
        

        
$google_order=preg_replace(array_map(array("ps_google","preg"),array_keys($values)),$values,$google_order);
        

        
$sql=preg_replace(array_map(array("ps_google","preg"),array_keys($values)),array_map("mysql_escape_string",$values),$sql_lines);
        
$google_db->query($sql);
        
while ($google_db->next_record()){
        
$values=array_merge($config,(array) $google_db->getCurrentRow());
        
$google_lines[]=preg_replace(array_map(array("ps_google","preg"),array_keys($values)),array_map("mysql_escape_string",$values),$google_line);
        
}
        

        
$values=$config;
        
$values['google_lines']=join("\r\n",$google_lines);
        
$google_order=preg_replace(array_map(array("ps_google","preg"),array_keys($values)),$values,$google_order);
        
echo $google_order;
        }
        return 
$valid;   
    }
}
DevelopmentProduction
VirtueMart  
2.0.12b
1.1.3
Joomla!  
2.5.6
1.5.14
Mysql 
5.5.8
5.0.51
PhP  
5.3.5
5.2.4

Camiband

  • Beginner
  • *
  • Posts: 8
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #24 on: May 30, 2010, 17:59:09 pm »
Could someone provde the step by step instructions needed to access the checkout.thankyou.tpl.php mentioned below:

Simplest way is to add the Google tracking code to the Thanks for ordering template - checkout.thankyou.tpl.php  - then you track sales and not site visits or click fraudsters.

Thanks.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27478
  • Always on vacation
    • Jenkin Hill Internet
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #25 on: May 30, 2010, 18:47:27 pm »
Could someone provde the step by step instructions needed to access the checkout.thankyou.tpl.php mentioned

Use FTP - the template is at
/components/com_virtuemart/themes/default/templates/pages/checkout.thankyou.tpl.php

download it, make a copy (for backup), edit the original using a good plain text editor & upload the new version with FTP.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

Camiband

  • Beginner
  • *
  • Posts: 8
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #26 on: June 01, 2010, 22:14:44 pm »
Looks simple enough, except that I haven't used FTP before.  Is there free FTP software that I can download or is FTP part of Joomla/Virtuemart?  You assistance is appreciated.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27478
  • Always on vacation
    • Jenkin Hill Internet
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #27 on: June 02, 2010, 18:22:34 pm »
If you have never used FTP then how have you installed security updates? All Joomla versions before 1.5.18 have known security issues.

A good open source FTP client is at http://filezilla-project.org/
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

Camiband

  • Beginner
  • *
  • Posts: 8
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #28 on: June 11, 2010, 17:08:14 pm »
My wife set up our site about 7 months ago through someone who provided little support.  The version we uses is OurJoomla! 1.5.10 Production/Stable.  Do I have a problem?

I've kind of come her web person by accident.  I do have FTP installed now  and I was about to follow your instructions regarding the  page: /components/com_virtuemart/themes/default/templates/pages/checkout.thankyou.tpl.php .  However I need further clarification.  Is this the "submit order" page or a Thank you page that Paypal checkout sends a customer back to after payment.  I noticed that this  option in Paypal is not clicked and when I put through a test order I was not redirected to a "Thank You" page on my site.  First things first I guess...how do I set up the Thank you page in Virtuemart.  thanks for your help, I realize these are very basic questions.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27478
  • Always on vacation
    • Jenkin Hill Internet
Re: Virtuemart conversion tracking with Google Analytics - HOW??
« Reply #29 on: June 11, 2010, 17:47:56 pm »
First upgrade Joomla ASAP. All versions before 1.5.18 have security issues and many have been hacked.

If you are really a beginner in all this then rather than edit the files you could simply install a module for use with Analytics.

I use Google Analytics 4 Virtuemart - it is not expensive, and does the job.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10