Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7924271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:40:51+00:00 2026-06-03T17:40:51+00:00

My company uses layout.phtml which is being shared by all the pages in the

  • 0

My company uses layout.phtml which is being shared by all the pages in the website,where I have inserted the basic Google Analytics code . Now I want to insert the Ecommerce tracking code into the partial head(any code specific to that page goes here)for only the confirmation page which is also sharing the layout.phtml page.
Do I have to include this again for ecommerce tracking code apart from the one in the Basic GA?

var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-XXXXX-X']);**

<—Ecommerece Tracking Code will go here—->

(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);
  })();

Else My Ecommerce tracking code, which is mainly :

_gaq.push(['_addTrans','','','','']);

_gaq.push(['_addItem','','','','','',]);

_gaq.push(['_trackTrans']);

which remains outside the Basic Google Analytics code. Would it still work?

This is how my code looks now when I view source my confirmation page:

var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-XXXXX-X']);

_gaq.push(['_trackPageview']);

(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);
})();

<!------Ecommerce tracking code for confirmation page--->

<?php if($this->tx_id == true && $this->rd['total'] == true){?>

_gaq.push(['_addTrans',<?=$this->tx_id ?>,'',<?=$this->rd['total']?>,'','','','','']);

<!------Items purchased------>

<?php foreach($this->dd as $sku=>$val) {

$i++;

$product_title= $this->pp[$sku]['title'];

$qty = $val['pt']['qty']; ?>

_gaq.push(['_addItem',

<?= $this->tx_id ?>,

<?= $sku ?>,

<?= $this->pp[$sku]['title'] ?>,

'',

<?= $this->pp[$sku]['price']?>,

<?= $qty ?>

 ]);

<?php }?>

 _gaq.push(['_trackTrans']); 

<?php  }?>

<!-------Ecommerce tracking code ends here---->

Could anyone please review it? Also Is there any way to test it before sending to prduction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:40:55+00:00Added an answer on June 3, 2026 at 5:40 pm

    You don’t need to duplicate the tracking code.
    addTrans, addItem and trackTrans can be called separately.

    (you’re code seems to be ok.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My company uses Accurev for source control, and for all its benefits, there's one
The software my company uses has a web service which signature is more or
I met a problem which is very strange, my company uses Visual Source Safe
I have an old project at our company that uses shell scripting a lot.
My company uses Subversion; I prefer Git. I have cloned the Subversion repository on
My company uses Vertica . We have Python applications that connect to it with
There is a website that my company uses that updates information about 3 specific
My company uses ASHX files to serve some dynamic images. Being it that the
A third party product we have at my company uses Oracle as a backend.
I have a seriously annoying problem. My company uses castor to marshall and unmarshall

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.