Zen Cart Logo
Forums / General Questions / E-commerce tracking code in checkout_success page

E-commerce tracking code in checkout_success page

Locked

Views: 5,737

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
14 Apr 2009, 11:24 PM
#1
jorgebnuk avatar

jorgebnuk

New Zenner

Join Date:
Dec 2006
Posts:
11
Plugin Contributions:
0

E-commerce tracking code in checkout_success page

Hi, hope someone can help me as I have spent several days and many hours searching for an answer with no luck.

I have google analytics code installed but want to install the e-commerce tracking code. This needs to be ONLY in the checkout_success.php.

The only page I can find for this is in: public_html/includes/templates/template_default/templates/tpl_checkout_success_default.php

In that page I have installed the google adwords conversion tracking code which works fine, but because this is a php file I placed the code anywhere in the page and works fine.

However, the e-commerce code needs to be placed just after the normal analytics code. My analytics code is installed in public_html/includes/templates/template_default/common/tpl_main_page.php but this makes the code to appear in ALL pages, so I cannot install the e-commerce code there because it will show in ALL pages.

Please I need help if someone knows the answer.. I need to put the e-commerce code just after the normal analytics code to appear ONLY in the checkout_success page.. where can I do this???

The Zen Cart version I use is 1.3.6

Please help.. !

15 Apr 2009, 1:24 AM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: E-commerce tracking code in checkout_success page

Put your regular adwords code in includes/templates/your_template/common/tpl_footer.php

Then make a copy of that file, put your extra code in it after the adwords tracking, and save it as includes/templates/your_template/checkout_success/footer.php

15 Apr 2009, 9:38 PM
#3
jorgebnuk avatar

jorgebnuk

New Zenner

Join Date:
Dec 2006
Posts:
11
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

Dear Bunyip,

Thanks a lot for your reply..
My analytics code is successfully installed here:

/public_html/includes/templates/template_default/common/tpl_main_page.php

The normal analytics code is tracking ok on that location, it tracks all pages...

You said I should install the normal analytics code in
**public_html??/**includes/templates/your_template/common/tpl_footer.php

but the tpl_footer.php does not have any /body tag to place the code before.. so dont know where I could place it on that php file to make the code appear before the /body tag.

Also, if I install the code successfully in the tpl_footer.php file, when I make a copy of it, you say I should put it in:

**public_html??/**includes/templates/your_template/checkout_success/footer.php... but I cannot see the directory "chekout_success".. do I need to create it?

Sorry for long questions.. hope you can help me with this...

Thanks, Jorge.

15 Apr 2009, 9:55 PM
#4
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: E-commerce tracking code in checkout_success page

Anywhere in the tpl_footer.php file will be before the /body tag.

To make it a little easier for you, you can keep your existing code in your edited tpl_main_page file. That file should be saved as public_html/includes/templates/YOUR_TEMPLATE/common/tpl_main_page.php, rather than in the template_default folder - otherwise it will get overwritten during an upgrade.

Make a copy of that tpl_main_page.php, add your new code where you need it to be before the /body tag. Then save that edited copy as
public_html/includes/templates/template_default/checkout_success/tpl_main_page.php

You will need to create the folder public_html/includes/templates/template_default/checkout_success - because it's a new folder, it won't get overwritten during an upgrade. The tpl_main_page.php there will **only **be used on your checkout_success page.

16 Apr 2009, 9:26 PM
#5
jorgebnuk avatar

jorgebnuk

New Zenner

Join Date:
Dec 2006
Posts:
11
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

Bunyip.. That is brilliant thank you so much!
I have installed the e-commerce code successfully with your guidance. It now shows only in the checkout_success page, and all other pages show the normal analytics code.. now I just need to wait some days to see if it's tracking properly..

Thanks again for your time! hope this helps others..
Jorge.

17 Apr 2009, 9:00 PM
#6
jorgebnuk avatar

jorgebnuk

New Zenner

Join Date:
Dec 2006
Posts:
11
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

My e-commerce activity is now being track by analytics.. this is great... my only silly question now is: I installed the code as it appears here: http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55528

One part of the code is like this:

pageTracker._addItem(

"1234",                                     // Order ID

"DD44",                                     // SKU

"T-Shirt",                                  // Product Name 

"Green Medium",                             // Category

"11.99",                                    // Price

"1"                                         // Quantity

);

pageTracker._trackTrans();

</script> Now my activities are being track as selling item T-Shirt and at 11.99 price. How do I make my products to be trackable??? I have about 100 products..!, how do I make the code to track each item sold?.. :shocking:
17 Apr 2009, 9:02 PM
#7
jorgebnuk avatar

jorgebnuk

New Zenner

Join Date:
Dec 2006
Posts:
11
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

Just to clarify my last post.. my e-commerce code is tracking the item T-shirt when I have a sale, this is because t-shirt is in my code, but I don't sale t-shirts, I sale over 100 different items.. ! and I need the code to register the sales of each item.. please help.. thanx:(

23 Jul 2009, 5:46 PM
#8
sirbuck avatar

sirbuck

Zen Follower

Join Date:
Jan 2007
Location:
Carlsbad, CA
Posts:
161
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

jorgebnuk:

Just to clarify my last post.. my e-commerce code is tracking the item T-shirt when I have a sale, this is because t-shirt is in my code, but I don't sale t-shirts, I sale over 100 different items.. ! and I need the code to register the sales of each item.. please help.. thanx:(

Were you able or was anyone able to fix this? I am installing the code on my store and I'm not sure what to do with that.

23 Jul 2009, 7:02 PM
#9
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: E-commerce tracking code in checkout_success page

You'll need to use php code on the checkout_success page to build the tracker code with the order contents.

24 Oct 2009, 12:51 PM
#10
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

bunyip:

You'll need to use php code on the checkout_success page to build the tracker code with the order contents.
Thanks for the support bunyip, I had the same problem as jeorge and it's good to have gotten this far.

My other solution would have been to define a constant to hold the conversion tracking code and only call it on the checkout_success page :) It wouldn't have made it through the upgrades though.

This thread is a few months old, does anybody know which variables hold the values?

24 Oct 2009, 10:11 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: E-commerce tracking code in checkout_success page

If your tracking tools are google tools, there are already a few full-featured addons that will take care of sending analytics data by installing them to your store.

If you're building your own, you can use the variables available in tpl_checkout_success as posted here: http://www.zen-cart.com/forum/showthread.php?t=131900

25 Oct 2009, 1:16 AM
#12
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

DrByte:

If your tracking tools are google tools, there are already a few full-featured addons that will take care of sending analytics data by installing them to your store.

If you're building your own, you can use the variables available in tpl_checkout_success as posted here: http://www.zen-cart.com/forum/showthread.php?t=131900

I had seen the "simple google analytics" but figured it would be easier to do it myself...

Just went ahead and installed it, configured it, and everything looks to be not-broken. Let's see if it still works tomorrow.

5 Nov 2009, 7:02 PM
#13
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

It works great. Except for Paypal, which doesn't trigger the checkout_success page.

5 Nov 2009, 10:43 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: E-commerce tracking code in checkout_success page

bobthemolder:

It works great. Except for Paypal, which doesn't trigger the checkout_success page.
PayPal Express Checkout does trigger the checkout-success page, which is another good reason to use the more sophisticated Express Checkout module instead of the older "IPN/Standard" module.

9 Nov 2009, 11:41 AM
#15
ckalech avatar

ckalech

New Zenner

Join Date:
Jun 2005
Posts:
11
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

We're also confused by this.

It seems obvious that we will need to replace the text in quotes below with a variable. Does anyone have the exact code with variables as it should be used in Zen Cart?

Thanks

pageTracker._addItem(

"1234", // Order ID

"DD44", // SKU

"T-Shirt", // Product Name

"Green Medium", // Category

"11.99", // Price

"1" // Quantity

);

9 Nov 2009, 1:10 PM
#16
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: E-commerce tracking code in checkout_success page

ckalech:

We're also confused by this.

It seems obvious that we will need to replace the text in quotes below with a variable. Does anyone have the exact code with variables as it should be used in Zen Cart?

Thanks

pageTracker._addItem(

"1234", // Order ID

"DD44", // SKU

"T-Shirt", // Product Name

"Green Medium", // Category

"11.99", // Price

"1" // Quantity

);

I was wondering about this too, but Simple GA already has it:
From simpleGoogleAnalytics\includes\templates\your_template\google_analytics\google_analytics.php
For Item Details:

echo "
pageTracker._addItem(
"". $order->fields['orders_id'] ."",
"". $products->fields['skucode'] ."",
"". $products->fields['products_name'] ."",
"". $category->fields['categories_name'] ."",
"". number_format($products->fields['final_price'], 2, '.', '') ."",
"". $products->fields['products_quantity'] . ""
);
";

For Transaction details:

pageTracker._addTrans(
"" . $order->fields['orders_id'] . "",
"". GOOGLE_ANALYTICS_AFFILIATION ."",
"". $google_analytics['ot_total'] ."",
"". $google_analytics['ot_tax'] ."",
"". $google_analytics['ot_shipping'] ."",
"". $order->fields['city'] ."",
"". $order->fields['state'] ."",
"". $order->fields['country'].""
);
";