Sending a transaction using Daemon Collector
Copy the link to the article
Copied

If you need to send a transaction on a site that uses the daemon collector to place orders in RetailCRM, then, to form a transaction, you need to add the specific function (for sending a transaction from Google Analytics) inside the successful transaction delivery condition in the daemon collector form.

Via analytics.js

<script type="text/javascript">
$(function() {
 $('#feedback-form').submit(function() {
 _rc('send', 'order', {
 'name': $(this).find('input[name=name]').val(),
 'email': $(this).find('input[name=email]').val(),
 'customTransactionId': url('?transaction_id'),
 'orderMethod': 'feedback',
 'callback': function(success, response) {
 if (success) {
 ga('ecommerce:addTransaction', {
 'id': response.id, // Transaction ID
 'affiliation': 'example.com', // Store name
 'revenue': '1500', // Total cost of the order
 'shipping': '250', // Delivery cost
 'tax': '' // Налог
 });
 ga('e commerce:send'); // Sending data
 alert('Thank you, your request is accepted! Its number: ' + response.id);
 } else {
 alert ('Unfortunately, the request could not be sent.');
 }
 }
 });
 return false;
 })
})
</script>

Via gtag.js

<script type="text/javascript">
$(function() {
 $('#feedback-form').submit(function() {
 _rc('send', 'order', {
 'name': $(this).find('input[name=name]').val(),
 'email': $(this).find('input[name=email]').val(),
 'customTransactionId': url('?transaction_id'),
 'orderMethod': 'landing-page',
 'callback': function(success, response) {
 if (success) {
 gtag('event', 'purchase', {
 "transaction_id": response.id,
 "dimension1": getRetailCrmCookie("_ga"),
 "affiliation": "Google online store",
 "value": 23.07,
 "currency": "USD",
 "tax": 1.24,
 "shipping": 0,
 });
 } else {
 alert('Unfortunately, the request could not be sent.');
 }
 }
 });
 return false;
 });
 });
</script>

Note

response.id is the external identifier of the order (externalId) in the system. When integrating, in the settings of the Google Analytics module, in the "Link transactions/events via" parameter, you must select the value "Order ID in the store".

Thank you for your feedback.
Was this article helpful?
No
  • Рекомендации не помогли
  • Нет ответа на мой вопрос
  • Текст трудно понять
  • Не нравится описанный функционал
Yes
Previous article
Specifics of configuring an integration between Universal Analytics and InSales
This article describes the specifics of adding a tracking code to InSales CMS.