Browse code

Fix some structural errors

Benjamin Roth authored on08/04/2019 11:13:25
Showing1 changed files
... ...
@@ -36,7 +36,7 @@
36 36
   [{/if}]
37 37
 [{/if}]
38 38
 
39
-[{if $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
39
+[{if $oViewConf->getActiveClassName() == 'thankyou'}]
40 40
 <script>
41 41
   // Order infos
42 42
   [{assign var="order" value=$oView->getOrder()}]
... ...
@@ -71,12 +71,12 @@
71 71
   [{/foreach}]
72 72
 
73 73
   [{if $googleTrackingId}]
74
-    gtag('event', 'purchase' {
74
+    gtag('event', 'purchase', {
75 75
       'transaction_id': '[{$order->oxorder__oxordernr->value}]',        [{* Transaction ID *}]
76 76
       'affiliation':    '[{$oxcmp_shop->oxshops__oxname->value|escape:"quotes"}]',      [{* Store name *}]
77 77
       'value':          '[{$sTotal}]',                                  [{* Grand Total *}]
78 78
       'shipping':       '[{$sShipping}]',                               [{* Shipping *}]
79
-      'tax':            '[{$sTax}]'                                     [{* Tax *}]
79
+      'tax':            '[{$sTax}]',                                     [{* Tax *}]
80 80
       'items': orderitems
81 81
     });
82 82
   [{/if}]
... ...
@@ -85,9 +85,9 @@
85 85
     gtag('event', 'conversion', {
86 86
       'send_to': '[{$googleAdsId}]/[{$googleAdsConvLabel}]',
87 87
       'transaction_id': '[{$order->oxorder__oxordernr->value}]',
88
-      'value':          '[{$sTotal}]',
88
+      'value':          '[{$sTotal}]'
89 89
     });
90 90
   [{/if}]
91 91
 
92 92
 </script>
93
-[{/strip}][{/if}]
94 93
\ No newline at end of file
94
+[{/if}]
95 95
\ No newline at end of file
Browse code

Optimize gtag code

Benjamin Roth authored on26/03/2019 18:10:59
Showing1 changed files
... ...
@@ -13,7 +13,6 @@
13 13
     gtag('js', new Date());
14 14
 
15 15
     gtag('config', '[{$googleTrackingId}]', { 'anonymize_ip': true });
16
-</script>
17 16
 [{/if}]
18 17
 
19 18
 [{if $googleAdsId}]
... ...
@@ -28,10 +27,13 @@
28 27
       gtag('config', '[{$googleAdsId}]', { 'anonymize_ip': true });
29 28
     </script>
30 29
   [{else}]
31
-    <script>
32 30
       gtag('config', '[{$googleAdsId}]', { 'anonymize_ip': true });
33 31
     </script>
34 32
   [{/if}]
33
+[{else}]
34
+  [{if $googleTrackingId}]
35
+    </script>
36
+  [{/if}]
35 37
 [{/if}]
36 38
 
37 39
 [{if $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
Browse code

Add google ads conversion label to settings

Benjamin Roth authored on26/03/2019 18:04:38
Showing1 changed files
... ...
@@ -3,6 +3,7 @@
3 3
 [{assign var="oConfig" value=$oViewConf->getConfig()}]
4 4
 [{assign var=googleTrackingId value=$oConfig->getConfigParam('sOxEsAnalyticsId')}]
5 5
 [{assign var=googleAdsId value=$oConfig->getConfigParam('sOxEsAdsId')}]
6
+[{assign var=googleAdsConvLabel value=$oConfig->getConfigParam('sOxEsAdsConvLabel')}]
6 7
 [{if $googleTrackingId}]
7 8
   <!-- Global site tag (gtag.js) - Google Analytics -->
8 9
   <script async src="https://www.googletagmanager.com/gtag/js?id=[{$googleTrackingId}]"></script>
... ...
@@ -80,7 +81,7 @@
80 81
 
81 82
   [{if $googleAdsId}]
82 83
     gtag('event', 'conversion', {
83
-      'send_to': '[{$googleAdsId}]/5c0rCMbkt5EBEMOv59YD',
84
+      'send_to': '[{$googleAdsId}]/[{$googleAdsConvLabel}]',
84 85
       'transaction_id': '[{$order->oxorder__oxordernr->value}]',
85 86
       'value':          '[{$sTotal}]',
86 87
     });
Browse code

Use universal website tag and include google ads

Benjamin Roth authored on26/03/2019 17:37:55
Showing1 changed files
... ...
@@ -2,22 +2,41 @@
2 2
 
3 3
 [{assign var="oConfig" value=$oViewConf->getConfig()}]
4 4
 [{assign var=googleTrackingId value=$oConfig->getConfigParam('sOxEsAnalyticsId')}]
5
+[{assign var=googleAdsId value=$oConfig->getConfigParam('sOxEsAdsId')}]
5 6
 [{if $googleTrackingId}]
6
-<script>
7
-  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
8
-    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
9
-    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
10
-  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7
+  <!-- Global site tag (gtag.js) - Google Analytics -->
8
+  <script async src="https://www.googletagmanager.com/gtag/js?id=[{$googleTrackingId}]"></script>
9
+  <script>
10
+    window.dataLayer = window.dataLayer || [];
11
+    function gtag(){dataLayer.push(arguments);}
12
+    gtag('js', new Date());
11 13
 
12
-  ga('create', '[{$googleTrackingId}]', 'auto');
13
-  ga('set', 'anonymizeIp', true);
14
-  ga('send', 'pageview');
14
+    gtag('config', '[{$googleTrackingId}]', { 'anonymize_ip': true });
15
+</script>
16
+[{/if}]
15 17
 
18
+[{if $googleAdsId}]
19
+  [{if !$googleTrackingId}]
20
+    <!-- Global site tag (gtag.js) - Google Ads -->
21
+    <script async src="https://www.googletagmanager.com/gtag/js?id=[{$googleAdsId}]"></script>
22
+    <script>
23
+      window.dataLayer = window.dataLayer || [];
24
+      function gtag(){dataLayer.push(arguments);}
25
+      gtag('js', new Date());
16 26
 
17
-  [{if $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
18
-  [{assign var="order" value=$oView->getOrder()}]
27
+      gtag('config', '[{$googleAdsId}]', { 'anonymize_ip': true });
28
+    </script>
29
+  [{else}]
30
+    <script>
31
+      gtag('config', '[{$googleAdsId}]', { 'anonymize_ip': true });
32
+    </script>
33
+  [{/if}]
34
+[{/if}]
19 35
 
20
-  ga('require', 'ecommerce');
36
+[{if $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
37
+<script>
38
+  // Order infos
39
+  [{assign var="order" value=$oView->getOrder()}]
21 40
 
22 41
   [{assign var="currate" value=$order->oxorder__oxcurrate->value}]
23 42
   [{if $oConfig->getConfigParam('blEnterNetPrice')}]
... ...
@@ -28,34 +47,44 @@
28 47
   [{math equation="sum - net" sum=$order->getTotalOrderSum() net=$order->getOrderNetSum() format="%.2f" assign="sTax"}]
29 48
   [{math equation="sum / rate" sum=$order->oxorder__oxdelcost->value rate=$currate format="%.2f" assign="sShipping"}]
30 49
 
31
-  ga('ecommerce:addTransaction', {
32
-    'id':           '[{$order->oxorder__oxordernr->value}]',        [{* Transaction ID *}]
33
-    'affiliation':  '[{$oxcmp_shop->oxshops__oxname->value|escape:"quotes"}]',      [{* Store name *}]
34
-    'revenue':      '[{$sTotal}]',                                  [{* Grand Total *}]
35
-    'shipping':     '[{$sShipping}]',                               [{* Shipping *}]
36
-    'tax':          '[{$sTax}]'                                     [{* Tax *}]
37
-  });
38
-
50
+  // Items
51
+  var orderitems = [];
39 52
   [{foreach from=$order->getOrderArticles() item=oOrderArticle}]
53
+    [{if $oConfig->getConfigParam('blEnterNetPrice')}]
54
+    [{assign var="oPrice" value=$oOrderArticle->getPrice()}]
55
+    [{math equation="sum / rate" sum=$oPrice->getNettoPrice() rate=$currate format="%.2f" assign="sPrice"}]
56
+    [{else}]
57
+    [{assign var="sPrice" value=$oOrderArticle->oxorderarticles__oxprice->value}]
58
+    [{/if}]
40 59
 
41
-  [{if $oConfig->getConfigParam('blEnterNetPrice')}]
42
-  [{assign var="oPrice" value=$oOrderArticle->getPrice()}]
43
-  [{math equation="sum / rate" sum=$oPrice->getNettoPrice() rate=$currate format="%.2f" assign="sPrice"}]
44
-  [{else}]
45
-  [{assign var="sPrice" value=$oOrderArticle->oxorderarticles__oxprice->value}]
46
-  [{/if}]
47
-
60
+    orderitems.push({
61
+      'id': '[{$order->oxorder__oxordernr->value}]',                          [{* Transaction ID *}]
62
+      'name': '[{$oOrderArticle->oxorderarticles__oxtitle->value|escape:"quotes"}][{if $oOrderArticle->oxorderarticles__oxselvariant->value}] [{$oOrderArticle->oxorderarticles__oxselvariant->value}][{/if}]',          [{* Product name *}]
63
+      'sku': '[{$oOrderArticle->oxorderarticles__oxartnum->value|escape:"quotes"}]',          [{* SKU *}]
64
+      'price': '[{$sPrice}]',                                                 [{* Preis pro Einheit *}]
65
+      'quantity': '[{$oOrderArticle->oxorderarticles__oxamount->value}]'      [{* Menge *}]
66
+    });
48 67
 
49
-  ga('ecommerce:addItem', {
50
-    'id': '[{$order->oxorder__oxordernr->value}]',                          [{* Transaction ID *}]
51
-    'name': '[{$oOrderArticle->oxorderarticles__oxtitle->value|escape:"quotes"}][{if $oOrderArticle->oxorderarticles__oxselvariant->value}] [{$oOrderArticle->oxorderarticles__oxselvariant->value}][{/if}]',          [{* Product name *}]
52
-    'sku': '[{$oOrderArticle->oxorderarticles__oxartnum->value|escape:"quotes"}]',          [{* SKU *}]
53
-    'price': '[{$sPrice}]',                                                 [{* Preis pro Einheit *}]
54
-    'quantity': '[{$oOrderArticle->oxorderarticles__oxamount->value}]'      [{* Menge *}]
55
-  });
56 68
   [{/foreach}]
57 69
 
58
-  ga('ecommerce:send');
59
-  [{/strip}][{/if}]
70
+  [{if $googleTrackingId}]
71
+    gtag('event', 'purchase' {
72
+      'transaction_id': '[{$order->oxorder__oxordernr->value}]',        [{* Transaction ID *}]
73
+      'affiliation':    '[{$oxcmp_shop->oxshops__oxname->value|escape:"quotes"}]',      [{* Store name *}]
74
+      'value':          '[{$sTotal}]',                                  [{* Grand Total *}]
75
+      'shipping':       '[{$sShipping}]',                               [{* Shipping *}]
76
+      'tax':            '[{$sTax}]'                                     [{* Tax *}]
77
+      'items': orderitems
78
+    });
79
+  [{/if}]
80
+
81
+  [{if $googleAdsId}]
82
+    gtag('event', 'conversion', {
83
+      'send_to': '[{$googleAdsId}]/5c0rCMbkt5EBEMOv59YD',
84
+      'transaction_id': '[{$order->oxorder__oxordernr->value}]',
85
+      'value':          '[{$sTotal}]',
86
+    });
87
+  [{/if}]
88
+
60 89
 </script>
61
-[{/if}]
62 90
\ No newline at end of file
91
+[{/strip}][{/if}]
63 92
\ No newline at end of file
Browse code

Initial commit

Benjamin Roth authored on31/08/2015 14:53:33
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,61 @@
1
+[{$smarty.block.parent}]
2
+
3
+[{assign var="oConfig" value=$oViewConf->getConfig()}]
4
+[{assign var=googleTrackingId value=$oConfig->getConfigParam('sOxEsAnalyticsId')}]
5
+[{if $googleTrackingId}]
6
+<script>
7
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
8
+    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
9
+    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
10
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
11
+
12
+  ga('create', '[{$googleTrackingId}]', 'auto');
13
+  ga('set', 'anonymizeIp', true);
14
+  ga('send', 'pageview');
15
+
16
+
17
+  [{if $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
18
+  [{assign var="order" value=$oView->getOrder()}]
19
+
20
+  ga('require', 'ecommerce');
21
+
22
+  [{assign var="currate" value=$order->oxorder__oxcurrate->value}]
23
+  [{if $oConfig->getConfigParam('blEnterNetPrice')}]
24
+  [{math equation="sum / rate" sum=$order->getOrderNetSum() rate=$currate format="%.2f" assign="sTotal"}]
25
+  [{else}]
26
+  [{math equation="sum / rate" sum=$order->getTotalOrderSum() rate=$currate format="%.2f" assign="sTotal"}]
27
+  [{/if}]
28
+  [{math equation="sum - net" sum=$order->getTotalOrderSum() net=$order->getOrderNetSum() format="%.2f" assign="sTax"}]
29
+  [{math equation="sum / rate" sum=$order->oxorder__oxdelcost->value rate=$currate format="%.2f" assign="sShipping"}]
30
+
31
+  ga('ecommerce:addTransaction', {
32
+    'id':           '[{$order->oxorder__oxordernr->value}]',        [{* Transaction ID *}]
33
+    'affiliation':  '[{$oxcmp_shop->oxshops__oxname->value|escape:"quotes"}]',      [{* Store name *}]
34
+    'revenue':      '[{$sTotal}]',                                  [{* Grand Total *}]
35
+    'shipping':     '[{$sShipping}]',                               [{* Shipping *}]
36
+    'tax':          '[{$sTax}]'                                     [{* Tax *}]
37
+  });
38
+
39
+  [{foreach from=$order->getOrderArticles() item=oOrderArticle}]
40
+
41
+  [{if $oConfig->getConfigParam('blEnterNetPrice')}]
42
+  [{assign var="oPrice" value=$oOrderArticle->getPrice()}]
43
+  [{math equation="sum / rate" sum=$oPrice->getNettoPrice() rate=$currate format="%.2f" assign="sPrice"}]
44
+  [{else}]
45
+  [{assign var="sPrice" value=$oOrderArticle->oxorderarticles__oxprice->value}]
46
+  [{/if}]
47
+
48
+
49
+  ga('ecommerce:addItem', {
50
+    'id': '[{$order->oxorder__oxordernr->value}]',                          [{* Transaction ID *}]
51
+    'name': '[{$oOrderArticle->oxorderarticles__oxtitle->value|escape:"quotes"}][{if $oOrderArticle->oxorderarticles__oxselvariant->value}] [{$oOrderArticle->oxorderarticles__oxselvariant->value}][{/if}]',          [{* Product name *}]
52
+    'sku': '[{$oOrderArticle->oxorderarticles__oxartnum->value|escape:"quotes"}]',          [{* SKU *}]
53
+    'price': '[{$sPrice}]',                                                 [{* Preis pro Einheit *}]
54
+    'quantity': '[{$oOrderArticle->oxorderarticles__oxamount->value}]'      [{* Menge *}]
55
+  });
56
+  [{/foreach}]
57
+
58
+  ga('ecommerce:send');
59
+  [{/strip}][{/if}]
60
+</script>
61
+[{/if}]
0 62
\ No newline at end of file