Post by thanos74 » Thu Feb 28, 2019 7:25 am

Hello, i want to add analytics snippet at checkout/success path.

The code is

Code: Select all

<!-- Event snippet for conversion page --> <script> gtag('event', 'conversion', { 'send_to': 'AW-0000000/xxxxxxxxx', 'transaction_id': '' }); </script>
As i see at https://support.google.com/google-ads/a ... mer%3Dtrue , i have to add "order ID" to to minimize duplicate conversions.

Sould be the code of "order ID" like 'transaction_id': '<%= order_id %>' ?
The path is /catalog/view/theme/default/template/common/success.twig , am i right ?

New member

Posts

Joined
Thu Nov 05, 2015 4:55 pm

Post by straightlight » Thu Feb 28, 2019 7:51 am

See this extension: https://www.opencart.com/index.php?rout ... n_id=24063 . Since you're using v3.x releases, in the XML file from that OCMod extension, change:

Code: Select all

<file path="catalog/view/theme/*/template/common/success.tpl">
	<operation> 
	<search><![CDATA[
	<?php echo $text_message; ?>
	]]></search>
	 <add position="before"><![CDATA[
	<!-- MIT : Order Id-->
	<?php if(isset($text_order_id)) { ?>
	<p><strong><?php echo $text_order_id;?></strong></p>
	<?php } ?>
	<!-- MIT : Order Id END-->
	]]></add>
	</operation> 
</file>
To:

Code: Select all

<file path="catalog/view/theme/*/template/common/success.twig">
	<operation> 
	<search><![CDATA[
	{{ text_message }}
	]]></search>
	 <add position="before"><![CDATA[
	{% if (text_order_id) %}
	<p><strong>{{ text_order_id }}</strong></p>
	{% endif %}
	]]></add>
	</operation> 
</file>
In your case, afterwards, you could simply replace this variable:
<p><strong>{{ text_order_id }}</strong></p>
with your JS code above.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Users browsing this forum: Bing [Bot] and 8 guests