jrnetwork Posted April 14, 2012 Share Posted April 14, 2012 I've been putting this coding into my file: templates\orderforms\default\complete.tpl but wondering whether this is still required given that Google Analytics is now built into the system: {php} $orderid = $this->get_template_vars('orderid'); $userid = $_SESSION["uid"]; // get client data $result = select_query("tblclients","city, state, country",array("id"=>$userid)); $data = mysql_fetch_array($result); $city = $data["city"]; $state = $data["state"]; $country = $data["country"]; $this->assign('city',$city); $this->assign('state',$state); $this->assign('country',$country); // get package name $result = select_query("tblhosting","packageid",array("orderid"=>$orderid)); $data = mysql_fetch_array($result); $packageid = $data["packageid"]; $result = select_query("tblproducts","name, type",array("id"=>$packageid)); $data = mysql_fetch_array($result); $name = $data["name"]; $type = $data["type"]; $this->assign('name',$name); $this->assign('type',$type); $this->assign('packageid',$packageid); {/php} <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', '{$orderid}', // order ID - required '', // affiliation or store name '{$amount}', // total - required '0', // tax '0', // shipping '{$city}', // city '{$state}', // state or province '{$country}' // country ]); // add item might be called for every item in the shopping cart // where your ecommerce engine loops through each item in the cart and // prints out _addItem for each _gaq.push(['_addItem', '{$orderid}', // order ID - required '{$packageid} - {$name}', // SKU/code - required '{$name}', // product name '{$type}', // category or variation '{$amount}', // unit price - required '1' // quantity - required ]); _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers _gaq.push(['_trackPageview', '/client/cart.php?a=complete&pid={$packageid}']); {literal} (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); {/literal} </script> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.