Analytics
5K members online now
5K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Ecommerce Opencart Implementation problems.

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello!

I am having trouble implementing my ecommerce conversion tracking in my opencart-based website.

First of all, the basic analytics code is implemented and works perfectly. I placed it in the head tag of my header.tpl.

Ecommerce is activated in my analytics account so it should track transactions, though it doesn't.

I have searched for my website through google and placed an order but it hasn't registered at all.

The following code has been inserted on my success page

 

<?php if(isset($orderDetails) && isset($orderProducts)) { ?>
<script type="text/javascript">

ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '<?php echo $orderDetails['order_id']; ?>',
'revenue': '<?php echo $orderDetails['total']; ?>',
'shipping': '10',
});
<?php foreach($orderProducts as $product) { ?>
ga('ecommerce:addItem', {
'id': '<?php echo $product['order_id']; ?>',
'name': '<?php echo json_encode($product['name']); ?>',
'quantity': '<?php echo $product['quantity']; ?>'
});
<? } ?>
ga('ecommerce:send');
ga('ecommerce:clear');
</script>
<?php } ?>

This is a code I adapted after searching around and replacing as I saw fit. I have no actual php knowledge and my knowledge of the website's variables and structure is little. Most implementations I saw(both using analytics.js and ga.js) were relying on placing a code similar to this on the success page.

I have used the chrome analytics debugger to no avail. The only thing that initializes is the main analytics function which I placed in the header. Some goals also get tracked but no conversions. Nothing about the ga send or clear functions placed at the end of the above code.

1 Expert replyverified_user

Re: Ecommerce Opencart Implementation problems.

Top Contributor
# 2
Top Contributor
Hi,

Does the transaction tracking code appear in the source code of the success page? If so, can you please paste it here? I'd be glad to help with debugging.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Ecommerce Opencart Implementation problems.

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
I have discovered the problem. I have modified the parameters that are sent
into the AddTransaction and Additem to random numbers instead of php
variables and transaction data is successfully sent to Analytics. I have
checked that on Analytics Debugger and everything works fine. The code is
as follows

when giving this information(which is totally irrelevant to actual
transaction data, the info is sent properly. I concluded that the php
variables that I thought I was using properly were actually unidentified
variables, so info wasnt passed to AddTransaction and addItem, which was
why the info wasn't sent. I am currently having trouble with where I find
this transaction data and how I send it.
forgot to mention, the code above is placed on the success page of my
website.

Re: Ecommerce Opencart Implementation problems.

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
I have discovered the problem. I have modified the parameters that are sent into the AddTransaction and Additem to random numbers instead of php variables and transaction data is successfully sent to Analytics. I have checked that on Analytics Debugger and everything works fine. The code is as follows


ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '1234',
'revenue': '100',
'shipping': '10',
});

ga('ecommerce:addItem', {
'id': '1234',
'name': 'nume',
'quantity': '1'
});

ga('ecommerce:send');

Oops, code didn't seem to appear...

Re: Ecommerce Opencart Implementation problems.

Top Contributor
# 5
Top Contributor
It looks good.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Ecommerce Opencart Implementation problems.

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Unable to do the same.
I'm a newbie but a bit knowledgeable with PHP Code (not PDO , which is used in OpenCart), could you help me what all variables should be used for echoing the value in opencart.