Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzaharova/c427f271c7ce2da930ce3295719a4ed8 to your computer and use it in GitHub Desktop.
Save uzaharova/c427f271c7ce2da930ce3295719a4ed8 to your computer and use it in GitHub Desktop.
diff --git a/design/themes/responsive/templates/addons/rus_yandex_metrika/hooks/checkout/order_confirmation.post.tpl b/design/themes/responsive/templates/addons/rus_yandex_metrika/hooks/checkout/order_confirmation.post.tpl
index dadc1d4..f94eaec 100644
--- a/design/themes/responsive/templates/addons/rus_yandex_metrika/hooks/checkout/order_confirmation.post.tpl
+++ b/design/themes/responsive/templates/addons/rus_yandex_metrika/hooks/checkout/order_confirmation.post.tpl
@@ -1,21 +1,24 @@
{if $order_info}
<script type="text/javascript">
var yaParams = {
- order_id: "{$order_info.order_id}",
- order_price: {$order_info.total},
- currency: "{$order_info.secondary_currency}",
- exchange_rate: 1,
- goods:
- [
- {foreach from=$order_info.products item=products}
- {
- id: "{$products.product_id}",
- name: {$products.product|strip_tags:false|json_encode nofilter},
- price: {$products.price},
- quantity: {$products.amount}
+ currencyCode: "{$order_info.secondary_currency|escape:javascript}",
+ purchase: {
+ actionField: {
+ id: "{$order_info.order_id}",
+ revenue: {$order_info.total}
},
- {/foreach}
- ]
+ exchange_rate: 1,
+ products: [
+ {foreach from=$order_info.products item=products}
+ {
+ id: "{$products.product_id|escape:javascript}",
+ name: {$products.product|strip_tags:false|json_encode nofilter},
+ price: {$products.price},
+ quantity: {$products.amount}
+ },
+ {/foreach}
+ ]
+ }
};
</script>
{/if}
diff --git a/js/addons/rus_yandex_metrika/func.js b/js/addons/rus_yandex_metrika/func.js
index 52e2128..c08292f 100644
--- a/js/addons/rus_yandex_metrika/func.js
+++ b/js/addons/rus_yandex_metrika/func.js
@@ -80,6 +80,8 @@
(w[c] = w[c] || []).push(function() {
try {
+ w.dataLayerYM = w.dataLayerYM || [];
+
_.yandex_metrika.settings.params = w.yaParams || {};
w['yaCounter' + _.yandex_metrika.settings.id] = new Ya.Metrika(_.yandex_metrika.settings);
@@ -93,7 +95,12 @@
&& goals_scheme[goal_name].controller == _.yandex_metrika.current_controller
&& goals_scheme[goal_name].mode == _.yandex_metrika.current_mode
) {
- w['yaCounter' + _.yandex_metrika.settings.id].reachGoal(goal_name, _.yandex_metrika.settings.params);
+ w.dataLayerYM.push({
+ 'ecommerce': {
+ 'currencyCode': _.yandex_metrika.settings.params.currencyCode,
+ 'purchase': _.yandex_metrika.settings.params.purchase
+ }
+ });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment