Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Google Analytics Event Tracking
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 07-31-2017, 03:18 AM
  zone1creative's Avatar 
zone1creative zone1creative is offline
 

eXpert
  
Join Date: Jan 2009
Location: Hove, UK
Posts: 240
 

Default Google Analytics Event Tracking

A customer of mine recently wanted to know which products and category pages were the most viewed on his site via Google Analytics.

You can use the Site Content section to see all page loads, but it was more difficult to see just the product for instance.

So I implemented Event tracking for page loads on product, category and static pages on X-Cart 4.

Using this javascript as an example for a product page load

Code:
$(function () { _gaq.push(['_trackEvent', 'Page Type View', 'Product', '234:Tennis Ball']); });

You can use the following

Code:
{if $main eq "product"} <script type="text/javascript"> $(function () {$ldelim} _gaq.push(['_trackEvent', 'Page Type View', 'Product', '{$product.productid}:{$product.product}']); {$rdelim}); </script> {elseif $main eq "catalog"} <script type="text/javascript"> $(function () {$ldelim} _gaq.push(['_trackEvent', 'Page Type View', 'Category', '{$current_category.categoryid|default:'0'}:{$current_category.category|default:'Home Page'}']); {$rdelim}); </script> {elseif $main eq "pages"} <script type="text/javascript"> $(function () {$ldelim} _gaq.push(['_trackEvent', 'Page Type View', 'Pages', '{$page_data.title}']); {$rdelim}); </script> {/if}

Here is a full example of the code
https://www.zone1creative.co.uk/know...pages-visited/
__________________
Pinakin Patel
Zone1 Creative Ltd
http://www.zone1creative.co.uk/
Reply With Quote

The following user thanks zone1creative for this useful post:
qualiteam (08-16-2017)
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:35 PM.

   

 
X-Cart forums © 2001-2018