Fireflight Posted July 22, 2010 Posted July 22, 2010 I'm trying to implement e-commerce tracking for Google Analytics and ran into this problem. Luckily I discovered that OSC already has a function to get the category ID from a product id. From there it was a fairly simple process, so I just thought I'd share my solution. This is my production code, so please modify it to your needs. $ga_category_id = tep_get_product_path($order->products[$i]['id']); $ga_category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $ga_category_id . "'"); $ga_category = tep_db_fetch_array($ga_category_query); echo '<input name="ga_category[' . $i .'][category]" type="hidden" value="' . $ga_category[categories_name] . '" />'; Replace $order->products[$i]['id'] with whatever variable contains your products id. $ga_category[categories_name] is what actually outputs the name of the category.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.