Analytics

Hi All,



I tried to get the analytics function to work when I was running 1.3.5 but could not find a way to get it to track from within the cart, so ended up adding the code manually to the bottom.tpl file and using it that way.



However, this does not track e-commerce so I have no idea how well my ad campaigns are running.



My question is, now I have upgraded to 1.3.5 SP3 and can see a lot of bugs have been fixed, is analytics one of them? Is the e-commerce tracking working out the box and does it require anything other than simply adding your ID in the appropriate add-on section and ticking the box? I would just change the code and try it but I am monitoring traffic at the moment and don’t really want to play around with things unnecessarily.



I am really keen to get this function working properly and it is my main concern with my current set-up (so much so I have even considered the possible need to jump to another cart :frowning: ).



I have searched and searched the forum for answers and nothing has worked previously, and with this being a new updated version I thought I would pose the question again as I am sure there must be other people in the same situation.



Any help would be much appreciated…

I am also having this problem.



Can anybody help?



Thanks.

I paid CS-cart for this code and it looks like it is working.



Here is the code to make analytics e-commerce work in 1.35



In ADDONS/GOOGLE_ANALYTICS/FUNC.PHP

Add the follwing at the end


function fn_get_product_category($product_id, $lang_code = '')
{
global $db_tables, $cart_language;

$lang_code = !empty($lang_code) ? $lang_code : $cart_language;

if (!empty($product_id)) {
return db_get_field("SELECT $db_tables[category_descriptions].category FROM $db_tables[category_descriptions] LEFT JOIN $db_tables[products_categories] ON $db_tables[category_descriptions].category_id=$db_tables[products_categories].category_id WHERE $db_tables[products_categories].product_id='$product_id' AND $db_tables[category_descriptions].lang_code='$lang_code' AND $db_tables[products_categories].link_type='M'");
}

return false;
}
function fn_get_product_sku($sku, $product_options, $option_name = 'foam_insert')
{
if (!empty($product_options) && is_array($product_options)) {
foreach ($product_options as $k => $v) {
if ($v['option_name'] == $option_name) {
$sku = $v['variant_name'];
}
}
}

return $sku;
}




In SKINS/YOUR_SKIN/CUSTOMER/ADDONS/GOOGLE_ANALYTICS/reporter.tpl



Replace whole file with:

```php {* $Id: reporter.tpl 5071 2008-04-03 06:25:44Z imac $ }



{
Track processed orders only *}



{if $settings.Addons.google_analytics_opts.track_ecommerce == “Y” && $order_info.status == ‘P’}


{/if} ```



This will work with the New Google Tracking codes

One more thing though, Google Analytics is having problems with their e-commerce tracking in that it doesn’t show all of the transactions. It will say something like 5 transactions but when you drill down on it it will show the real number like 10 but with the other five as $0. The individual products will show up but not the total. A few days later some of the transactions will show up.



Google Tech support admitted the problem and they said they are working on it.

Hmmm… I am running 1.3.5 SP2 and this still doesnt seem to work for me.



Any other suggestions?



Thanks in advance.

As far as the e-commerce goes, it does take a full 24 hours for data to show up and it could take as much as 3 to 4 days.



Also, if you use the code above for the new tracking code, make sure that tracker.tpl uses the new tracking code


```php {* $Id: tracker.tpl 4995 2008-03-27 07:08:27Z zeke $ *}



```

I noticed that the tracking code doesn’t have a “-1” at the end. When I log into my analytics account and compare the code, it’s supposed to have it, so I added it to my tracker.tpl file like so:



var pageTracker = _gat._getTracker(“{$settings.Modules.google_analytics_opts.tracking_code}-1”);



I’ll let you guys know if it works in a few days.

Since we are on this subject.



On Google’s end I have done…



I have tried all 3 Match Type’s Exact, Head, Regular. Which one is correct?



My order complete goal. /index.php?target=orders&mode=details&order_id=([0-9]+)&confirmation=Y



Is this correct?

Let’s not get confused here. You mention above to use the file…

{* $Id: reporter.tpl 5071 2008-04-03 06:25:44Z imac $ }



I have a newer version…

{
$Id: reporter.tpl 52 2008-04-23 00:50:15Z svn_snapshot $ *}



Are we talking about 1.3.5 SP3 here. Would you not use the newer file?



Please verify.

[quote name=‘keith’]Let’s not get confused here. You mention above to use the file…

{* $Id: reporter.tpl 5071 2008-04-03 06:25:44Z imac $ }



I have a newer version…

{
$Id: reporter.tpl 52 2008-04-23 00:50:15Z svn_snapshot $ *}



Are we talking about 1.3.5 SP3 here. Would you not use the newer file?



Please verify.[/QUOTE]



Is there any difference between the two?

yes there is.

[quote name=‘keith’]yes there is.[/QUOTE]





Keith,



I am not sure of the difference, but I did have to have CS-cart change the code to include the category and the product options instead of the category being blank and no options. Maybe that is the difference. As I said before, I paid them to make the code work for 1.34 and 1.35 and it seems to be working fine.



As a side note: As per my previous post about data errors in google - Google has announced that they were having problems and they are being corrected now.



[url]http://www.google.com/support/googleanalytics/bin/answer.py?answer=95811&hl=en_US[/url]

Are you using service pack 3 the latest version for 1.3.5? or did they do the mod for you for the older service pack 1 or 2? If so, I would say they updated the code for the service pack 3. Also can you answer #8 above?

It is for 1.35SP3.



As for #8 above use Regular Expression Match. I find that the Analytics info on this forum is very confusing and hard to follow but there are some really good posts from other members.

I am pretty new at the analytics stuff, and couldnt figure out why it wouldnt work for me. I am sure you have already tried this, but to any nooBs out there overlooking the same thing - hopefully this will help.



So, I signed up for an analytics account, and then I found a tracking code that looked like this “UA-2xxxxx2-2” (replace the ‘x’ with real numbers that you find when you go to the sample code section of analytics page). It was actually part of their sample code that they said to paste into your web templates. However I found that when I pasted this tracking code into the following input box, it worked.



Home > Addons > Google Analytics > Tracking Code



(I am using cs-cart 1.3.5 sp2)

[quote name=‘shockalotti’]I am pretty new at the analytics stuff, and couldnt figure out why it wouldnt work for me. I am sure you have already tried this, but to any nooBs out there overlooking the same thing - hopefully this will help.



So, I signed up for an analytics account, and then I found a tracking code that looked like this “UA-2xxxxx2-2” (replace the ‘x’ with real numbers that you find when you go to the sample code section of analytics page). It was actually part of their sample code that they said to paste into your web templates. However I found that when I pasted this tracking code into the following input box, it worked.



Home > Addons > Google Analytics > Tracking Code



(I am using cs-cart 1.3.5 sp2)[/QUOTE]



Just to add a few more things for the complete novice.



Adding the tracking code as above works great and google will show great reports as to where traffic is coming from, keywords, etc.



To go a little further, you can add a Goal. This tells google that an order was placed. Google will then be able to tell you how many orders came from each website, each keyword, etc.



To go further than that, you can add a funnel. This will show how many people enter the cart and how many people continue on to each checkout step.



And finally, to really get the most out of Analytics, you can setup e-commerce. Similar to the Goals report, this will show you the value of the sales that you are getting so you can see the dollar volume of the orders coming in. It will also tell you which keywords are working and whether you are spending your adwords dollars effectively.



Google’s Analytics is not perfect but it is Free.

Someone please answer my question.



My order complete goal in Analytics is…

/index.php?target=orders&mode=details&order_id=([0-9]+)&confirmation=Y



Is this link correct, if not what is it?

[quote name=‘keith’]Someone please answer my question.



My order complete goal in Analytics is…

/index.php?target=orders&mode=details&order_id=([0-9]+)&confirmation=Y



Is this link correct, if not what is it?[/QUOTE]



That is the correct code as per Cs-cart support.



See this thread:



[url]http://forum.cs-cart.com/showthread.php?t=3752&highlight=analytics+1.35[/url]

Hi Guys,



Sorry for my absence since starting this thread, so here is an update:



Having updated to 1.3.5-SP3 recently (which went unbelievably smoothly I must say) I decided to hell with it as I had made the huge jump of risking my live stores update why not try the new code out completely after all what harm is a few days missed tracking?



The upshot is that the update has solved all issues for me with Analytics, having removed all the code for tracking that I had manually added in 1.3.5 (the update had preserved my code) and simply adding my Analytics ID in the appropriate box in ‘Add-ons’ everything and I mean everything is working smoothly, e-commerce is tracking, visitors are all tracking with keyword conversions etc.



For those having problems I would suggest maybe backing up, removing any manually added code and giving the in-cart code a try (this is only to those who have upgraded to 1.3.5-SP3 though as I am 99.9% certain previous versions do not work correctly out of the box).



Hope this helps

Actually I must add, the one thing that is not working is Goal Value tracking just in case my above post misleads anyone…



I am working on this but whilst e-commerce itself is tracking correctly and actual goals and the funnel are showing correctly just not any value in the goal I must say this bit is not high on my list of priorities.


[QUOTE]Someone please answer my question.



My order complete goal in Analytics is…

/index.php?target=orders&mode=details&order_id=([0-9]+)&confirmation=Y



Is this link correct, if not what is it?[/QUOTE]



Keith in Analytics you need to add backslashes to certain parts of that code like this:



^/index.php?target=orders&mode=details&order_id=([0-9]+)&confirmation=Y



Actually I do not remember if analytics added that for me or I added it manually so check out the goal in your own settings first see if the backslashes are already there.