Post by dol4er » Thu Feb 22, 2018 3:23 am

Can someone help me with adding the Google Adwords Tracking Pixel code to the checkout success page only, between <head> and </head>?

Where do I need to add the Google code to do this?

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Thu Feb 22, 2018 7:02 am

In your catalog/controller/common/header.php file, in the index() method, you could add:

Code: Select all

if (!empty($this->request->get['route'])) {
    $data['route'] = $this->request->get['route'];
} else {
    $data['route'] = '';
}
Then, in your catalog/view/theme/<your_theme>/template/common/header.tpl file, you could use an IF conditional statement like:

Code: Select all

<?php if (!empty($route) && $route == 'checkout/success') { ?>
    // Your JS code here
<?php } ?>
or on higher OC versions:

Code: Select all

<?php if (!empty($route) && $route == 'common/success') { ?>
    // Your JS code here
<?php } ?>
Last edited by straightlight on Thu Feb 22, 2018 7:43 am, edited 2 times in total.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dol4er » Thu Feb 22, 2018 7:32 am

"Notice: Undefined variable: route in /catalog/view/theme/primave/template/common/header.tpl on line 18"

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by dol4er » Thu Feb 22, 2018 3:16 pm

Thank you for the suggestions but it doesn't work again.

The error message disappeared but the conversion code does not appear in the code of the checkout/success page, unfortunately.

I was looking around the internet about this issue but no luck. I found instructions for implementing the old Google Conversion Pixel code into the Analytics Extension module but they seem to have changed the code, it looks in a different way and the instructions does not apply. I didn't expect this to be that hard considering that almost every online store advertise in Google Adwords and the Conversion Pixel is a must...

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Thu Feb 22, 2018 6:47 pm

The error message disappeared but the conversion code does not appear in the code of the checkout/success page, unfortunately.
According to my instructions above, there are two possible instructions provided for the routes. Based on your analysis, only one route has been tried.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dol4er » Thu Feb 22, 2018 11:11 pm

Well, I tried the checkout/success method because that's the route of the last page of the checkout process.

I didn't try the common/success because there is no such part in the URL... you wrote it's for newer OC versions...

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Fri Feb 23, 2018 6:27 am

You could also use the route detection directly with your Google JS code from your catalog/view/javascript folder and add another JS call in your header.tpl file between the <head></head> . This way would be more easier.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dol4er » Fri Feb 23, 2018 7:35 am

Thank you but I am not sure I understand. I'd really appreciate if you find some time to write the exact code and where it has to be added in order to make things work. Thank you!

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Fri Feb 23, 2018 9:31 am

It would be harden to provide the exact code from a Google code you haven't provided on the first post. What is it to add exactly?

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dol4er » Fri Feb 23, 2018 4:05 pm

The code is standard Google Adwords Conversion Tracking Pixel. It has to be placed only on the final checkout page so that it can count the number of successful orders.

<script>
gtag('event', 'conversion', {
'send_to': 'AW-8348324734/UI4H53GB4Y54YV4UO',
'transaction_id': ''
});
</script>

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Fri Feb 23, 2018 8:10 pm

dol4er wrote:
Fri Feb 23, 2018 4:05 pm
The code is standard Google Adwords Conversion Tracking Pixel. It has to be placed only on the final checkout page so that it can count the number of successful orders.

<script>
gtag('event', 'conversion', {
'send_to': 'AW-8348324734/UI4H53GB4Y54YV4UO',
'transaction_id': ''
});
</script>
Then, it is contradictory compared to the top replies. You were looking to add this code within the success page but in reality you are looking to add this code at the final checkout page which would make more sense. I would suggest the load of a JS file from PHP in your order total: Total module within the confirm method of the catalog/model/extension/total/total.php file. This will load the JS file in-between the <head></head> of your header.tpl file automatically and only upon successful checkout transactions. Although, still take note that this successful order at this step may not necessarily mean that it may remain a successful order since an order can still be reverted as cancelled from the order statuses unless the order being completed from the admin orders or from an automated API already granting the order as being completed (more expensive package from providers).

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dol4er » Fri Feb 23, 2018 9:43 pm

Nothing is contradictory to the top replies. Of course it has to be added to the success page because it has to track successful orders. Actually, the success page is the final page of the checkout process because you complete the order, you get the summary and you close the website. What's more final than that?

Unfortunately, it seems to me that you are more interested in making unsuccessful tries to find errors/contradictions/missing information in my posts than trying to help solving the problem. In total, 4 out of 7 posts you are criticizing my posts which is not very helpful and polite of you. None of your critics is justified, to my opinion.

I really hope there is someone in this forum who is really willing to help with this thing but it doesn't seem like there is for now.

This is Google Adwords Conversion Tracking Pixel, for God's sake... how can this be so hard to do and nobody can help me? :( Every online store should try to advertise in Adwords and use a Google Tracking Pixel... unbelievable...

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Sat Feb 24, 2018 1:20 am

What's more final than that?
I see. On your URL bar in your browser, manually try to add the checkout/success route or the common/success route. Users who types the route manually can still see the success page which means, according to your theory above, the success is the final page for successful order. If so, how can a successful order be described in this case if there are no order IDs related to their transaction from the browser when the query is manually typed? In addition, why would we need to have the confirm() method from the order totals if the success page can already handle it?

Those are the questions you should rather ask yourself before posting since Opencart already provides the success page publicly on the browser without the need to rely on a specific order ID which means your Google code will have no purpose on this particular page other than if an order ID is implied. While having an order ID implicated with an order, logically speaking, the best location would be in the order totals confirm() method. In other words, it is still contradictory facts since you did say:
the final checkout page
On more recent version, this is why this contradictory route has been moved to the common folder so to avoid further confusions by users since the final checkout step is the position from the flow where customers hits the: confirm button before being redirected to the common/success page upon successful orders.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dol4er » Sun Feb 25, 2018 3:19 am

I tried the codes you suggested and none of them worked, unfortunately. Instead of figuring out why the codes do NOT work, you start writing nonsense. It's a shame that you have almost 9000 posts... you wasted so much time to write bullsh*t and you could have just tried to help by giving me the right code and right file to put it. Thank you anyway, wish you all the best.

Newbie

Posts

Joined
Sun Dec 31, 2017 4:38 pm

Post by straightlight » Sun Feb 25, 2018 5:30 am

Where it doesn't really make sense right now is the lack of information you are providing on the topic so for supporters to be able to help you. As explained on many occasions generally on the forum, the Opencart platform isn't about magical and candy lands, and Cinderella where everything can work by itself. It is rather understanding that using a platform requires minimal skills (and not talking about technical subjects particularly). Owning a website and handling a platform is part of a webmaster's responsibility to manage.

While supporters may want to provide assistance, an OP must also be able to provide as much information in order to clarify the features he's using in the platform, and that by first reading the most recent forum rules that is already provided. Due to the countless possibilities of extensions that can be installed, one-to-many-to-unlimited people needs to understand the sizeless factors that users have been reporting over the years on the forum and on Github Opencart.

Using Opencart does not require technical skills but rather the proper understanding based on the marketing relations, since Opencart is mainly about selling products and services to customers with the most possible ways to complete the sales and the most fundamental and conceptual ways that supporters are hoping; not to see a topic about a reversed order status ID that wasn't necessarily reversed by Opencart itself.

This topic, in addition, is no exception. You are requiring assistance on using Google codes which is excluded from the Opencart core and needs to be added to the final checkout page. As explained on my previous reply, the confirm() method in your installed order status is where the code would be more relevant. However, if you are looking to add your JS code in your success page, you can always look for an extension on the marketplace.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 15 guests