Jump to content

Do I still require this GA Coding?


jrnetwork

Recommended Posts

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>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated