Post by storm-cloud » Mon Oct 22, 2012 10:12 am

I assume nobody has worked out how to insert the corresponding category into the tracking code (rather than hardcoding the word "Product")?

Active Member

Posts

Joined
Wed Feb 22, 2012 8:07 am

Post by FFCalberto » Tue Nov 06, 2012 7:18 pm

philbydevil wrote:Try this xml for 1.5.4.1:
vqmod-google-analytics-ecommerce-1541.xml
Hi,
i think this topic is really useful for Opencarter who uses Google Analytics/Merchant/Adwords.

This vqmod seems a right alternative to the mod "google analytics expert", am I right?

What's precisely this mod for?
i've read
"passes the value of the transaction and the order details to the GA servers."

My end is to have Tracked the conversion of completed purchases.
And i don't want a fixed "Conversion Value" field , as suggested by the Google guide.

It would be great if these values ($TotalValue) of the orders can be displayed in Analytics and Adwords (already linked to Merchant).

Can this vqmod do this yet?

Thanks in advance

Newbie

Posts

Joined
Thu Jul 19, 2012 6:17 pm

Post by v-v » Thu Nov 08, 2012 3:01 am

storm-cloud wrote:Just wondering if anyone has worked out how to include the product category variable?

I assume an extra database query needs to be included but I can't quite work this out...

Edit: JhauraW, I have just noticed that you removed the Google Analytics Account ID from the script. This is actually required for the tracking to work correctly.
Hi, I am wonder as well how to include category ...

v-v
Active Member

Posts

Joined
Wed Jun 16, 2010 10:09 pm

Post by Ed_Rolla » Sat Nov 17, 2012 3:29 am

philbydevil wrote:Try this xml for 1.5.4.1:
vqmod-google-analytics-ecommerce-1541.xml
You may have to change this line of code:

Code: Select all

<file name="catalog/view/theme/*/template/common/success.tpl">
The * may need to be changed to your theme name, but I think that * means ALL themes....
Phenomenal work, Philbydevil!
But, somehow I'm getting error when trying to access a variable's value. For instance, if I just try

Code: Select all

<?php echo $orderDetails['total'];?>
I get the error message:
Undefined variable: orderDetails in <b>/home/.../template/common/success.tpl</b> on line <b>43</b>
Any idea on where I might be going wrong?
Anyone? ???

WIP Design Publicidade e Marketing Digital


User avatar
New member

Posts

Joined
Sun Jul 15, 2012 12:16 am
Location - Brazil, Rio de Janeiro

Post by moneycarlo » Tue Nov 27, 2012 1:30 am

just guessing here but maybe put single quotes around it?
'<?php echo $orderDetails['total']; ?>'

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by OSWorX » Tue Nov 27, 2012 4:40 pm

Ed_Rolla wrote:
philbydevil wrote:Try this xml for 1.5.4.1:
vqmod-google-analytics-ecommerce-1541.xml
You may have to change this line of code:

Code: Select all

<file name="catalog/view/theme/*/template/common/success.tpl">
The * may need to be changed to your theme name, but I think that * means ALL themes....
Phenomenal work, Philbydevil!
But, somehow I'm getting error when trying to access a variable's value. For instance, if I just try

Code: Select all

<?php echo $orderDetails['total'];?>
I get the error message:
Undefined variable: orderDetails in <b>/home/.../template/common/success.tpl</b> on line <b>43</b>
Any idea on where I might be going wrong?
Anyone? ???
Simply means that you not setting the variable $orderDetails inside the controller.

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by storm-cloud » Thu Feb 21, 2013 6:42 am

Would ANYONE know how to call on the category for the tracking code?

Rather than hardcoding the word "Product", it really would be much better to have the category available in analytics. This way it is possible to filter out categories to see which are performing better than others.

I have been trying all night without success. I have outlined the steps below which I have have taken but my coding ability is not quite up to the task so I know that this is not correct.

1) In catalog/model/checkout/order.php add code to query the database to obtain the product category. This is the code I have tried to use but I am not sure if this is correct.

Code: Select all

public function getOrderCategory($product_id)
{
	$query = $this->db->query("SELECT " . DB_PREFIX . "category_description.name " . "FROM " . DB_PREFIX . "category_description LEFT JOIN " . DB_PREFIX . "product_to_category ON " . DB_PREFIX . "product_to_category.category_id = " . DB_PREFIX . "category_description.category_id " . "WHERE " . DB_PREFIX . "product_to_category.product_id = '" . (int)$product_id ."'");
	if (isset($query->row['name'])) {
		return $query->row['name'];
	} else {
		return 'Uncategorised';
	}
}
2) In catalog/controller/checkout/success.php add a line of code to set where the category information is being called from. This is the code I have added but I have a feeling that this is not correct.

Code: Select all

$this->data['orderCategory'] = $this->model_checkout_order->getOrderCategory($this->session->data['product_id']);
3) Modify the tracking code to insert the category. What to change this to?

Code: Select all

'<?php echo json_encode('Products'); ?>'
I am happy to make a donation (am I allowed to say this?) if anyone can help!

Active Member

Posts

Joined
Wed Feb 22, 2012 8:07 am

Post by spaniakos » Fri Feb 22, 2013 11:36 pm

i am working on it on an OC 1.5.1.3
i got it working (the original vq mod)
added some staff ( google adwords convertion tracking )
so far so good.

after that i tried adding category.
i managed to read the first category name (ex. if a product have 3 categories it will always read the first delivered from my query. )
but now somehow the order is not showing to analytics page :p

i will stick to it , and will post code etc.

Newbie

Posts

Joined
Fri Feb 22, 2013 11:17 pm

Post by spaniakos » Fri Feb 22, 2013 11:55 pm

in return of my previews commend.

i made some modifications in the script for oc 1.5.1.3 so it reads category names for each product.
plus i added the code for adwords conversion tracking because its in the same file success.tpl , so i thought there is no reason to make a separate vqmod script.

1) paste this after <?php } ?> in the script

Code: Select all

<!-- Google Code for xxxxxxx Purchace Conversion Page -->
<script type="text/javascript">

  var google_conversion_id = 1234567890;
  var google_conversion_language = "en_US";
  var google_conversion_format = "1";
  var google_conversion_color = "666666";
  var google_conversion_label = "Purchase";
var google_conversion_value = <?php echo $orderDetails['total']; /* total */ ?>;

</script>
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height=1 width=1 border=0 src="http://www.googleadservices.com/pagead/conversion/1234567890/?value=<?php echo $orderDetails['total']; /* total */ ?>&label=jh2jCIX01AQQq4LN2QM&guid=ON&script=0"/>
</div>
</noscript>
in the scripts it is included a modified sample from google page.
change the nessesery values and you are done.

2) added this on success.php section of the script

Code: Select all

$this->data['orderCategory'] = $this->model_checkout_order->getOrderCategory($this->session->data['order_id']);
3) added this on order.php section of the script

Code: Select all

public function getOrderCategory($order_id)
{
   $query = $this->db->query("SELECT " . DB_PREFIX . "category_description.name, " . DB_PREFIX . "order_product.product_id FROM " . DB_PREFIX . "category_description LEFT JOIN " . DB_PREFIX . "order_product ON " . DB_PREFIX . "order_product.order_id = '" . (int)$order_id . "' LEFT JOIN " . DB_PREFIX . "product_to_category ON " . DB_PREFIX . "product_to_category.category_id = " . DB_PREFIX . "category_description.category_id WHERE " . DB_PREFIX . "order_product.product_id = " . DB_PREFIX . "product_to_category.product_id AND " . DB_PREFIX . "category_description.language_id =1 GROUP BY product_id ORDER BY product_id ASC"); 
   return $query->rows;
}
4) added this to where 'Products' was

Code: Select all

$orderCategory[$i]['name']
i will start making an adwords remarketing code vqmod as well.

if i get permission from the original author of this script i will added it to extension repository.
please test if its working on your version of OC and report back :D
<< check file comment for some info >>

*thanks to all in all this pages that made me understand and modify the script.
use at will at your sites, but please respect the work made and do not sell this script.
this way we can continue to share our work with you all !

Attachments

need changed for conversion , OC 1.5.1.3 tested. for 1.5.2.1 change create( to addOrder(


Newbie

Posts

Joined
Fri Feb 22, 2013 11:17 pm

Post by dansk » Fri Mar 01, 2013 4:25 am

philbydevil wrote:Try this xml for 1.5.4.1:
vqmod-google-analytics-ecommerce-1541.xml
Thanks for your earlier ecommerce tracking VQMOD delivery. Come in handy!
How can I (instantly) check if it's delivering the needed variable to Google Analytics, by doing a dummy purchase?

Regards.

"Drop carts, not bombs"


Newbie

Posts

Joined
Wed Jan 25, 2012 4:50 am

Post by spaniakos » Mon Apr 01, 2013 6:44 pm

thats an option.
you can also install Google chrome extension : Google tag assistant , to check if all is ok ;)

Newbie

Posts

Joined
Fri Feb 22, 2013 11:17 pm

Post by spaniakos » Wed Apr 03, 2013 6:54 pm

i am planning to release this mod to the extensions repo as a free extension

can you please tell me , is it working for you ?
this is tested on a opencart 1.5.1.3
i am going to make it for last version too.
if you have had any problems at all , please report them so i can handle them and make a release for as many as possible versions .

thanks

Newbie

Posts

Joined
Fri Feb 22, 2013 11:17 pm

Post by stringsetc » Sat Apr 27, 2013 10:58 pm

im getting the following noitce in the error log. i've tried clearing the cache and still happens, everything seems to work, just a bit annoying .

"2013-04-27 14:51:14 - PHP Notice: Undefined variable: orderDetails in /home/www2/public_html/vqmod/vqcache/vq2-catalog_view_theme_gentle_template_common_success.tpl on line 63
2013-04-27 14:51:14 - PHP Notice: Undefined variable: orderDetails in /home/www2/public_html/vqmod/vqcache/vq2-catalog_view_theme_gentle_template_common_success.tpl on line 70"

any ideas?

Active Member

Posts

Joined
Thu Feb 16, 2012 11:59 pm

Post by moneycarlo » Fri May 03, 2013 3:55 am

spaniakos wrote:i am planning to release this mod to the extensions repo as a free extension

can you please tell me , is it working for you ?
this is tested on a opencart 1.5.1.3
i am going to make it for last version too.
if you have had any problems at all , please report them so i can handle them and make a release for as many as possible versions .

thanks
I know the version i updated this for was working on 1.5.2.2 but have not tried any of the latter ones since.

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by yowchuan » Fri May 24, 2013 10:25 pm

I am getting this error... any idea how I can fix it?

OC 1.5.5.1

Code: Select all

*******************************Fri.log********************************
---------- Date: 2013-05-24 08:07:49 ~ IP : 113.210.0.108 ----------
REQUEST URI : /index.php?route=checkout/confirm
MOD DETAILS:
   modFile   : /home/vcom/public_html/vqmod/xml/vqmod_catalog_google_analytics_e-commerce_adwords_conversion.xml
   id        : Google Analytics - E-Commerce
   version   : 1.0.0
   vqmver    : 1.0.8
   author    : added convertion tracking by darkraven-spaniakos
SEARCH NOT FOUND (ABORTING MOD): public function create($data) {
----------------------------------------------------------------------

New member

Posts

Joined
Wed Feb 06, 2013 2:39 am

Post by moneycarlo » Thu Jun 27, 2013 1:30 am

probably hasnt been updated for 1.5.5.1. The script is failing because it cannot find this line in the "catalog/model/checkout/order.php" file:

Code: Select all

public function create($data) {

Looks like that function has changed, so you'd have to look at your order.php and see what it says. maybe they just renamed the function in it. you should be able to review the changes on github

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by yowchuan » Mon Jul 01, 2013 3:46 am

I guess my best bet is to manually add the tracking variables into the code.

Just out of curiosity, how do you guys actually keep an inventory on the inevitable manual code edits you've done to OpenCart and making sure that you don't overwrite them when you upgrade to the latest version of OpenCart?

New member

Posts

Joined
Wed Feb 06, 2013 2:39 am

Post by moneycarlo » Wed Jul 03, 2013 10:28 pm

Most of these are done vqmods so they dont overwrite the existing code. when you decide to upgrade (which there usually isn't a reason to do for every version) then you test and see which vqmods fail and fix them from there.
so your vqmod folder is more or less your inventory of what needs to be updated when a new release comes out.

Also, OC uses like an override process where it'll look at your custom file before the standard default. So if you need to edit a file directly, you'll want to add it into your theme folder (using same folder structure) and it'll pull from there first and if it doesn't exist it'll use the default one.

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by yowchuan » Fri Jul 12, 2013 1:59 am

Thanks moneycarlo for your reply!

New member

Posts

Joined
Wed Feb 06, 2013 2:39 am

Post by blizeH » Wed Aug 07, 2013 9:57 pm

Thank you so much for this, we were going to put a 'where did you hear about us' select item onto the store, but this is a much better solution! Hopefully get the vqmod working later :)

New member

Posts

Joined
Sat Jan 14, 2012 4:20 am
Who is online

Users browsing this forum: No registered users and 1 guest