Skip to content

Commit 85b6c36

Browse files
authored
Merge pull request #57 from MzHyde/feature/optimize-pagespeed
Feature/optimize pagespeed
2 parents 4ef5914 + 5a95122 commit 85b6c36

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

Resources/config.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@
102102
Changes to the content of this field can break the funcionality of Google Tag Manager and should
103103
therefore only be done by experienced users.
104104
]]></description>
105+
</element>
106+
<element scope="shop" type="boolean">
107+
<name>wbmTagManagerPagespeed</name>
108+
<label lang="de">Pagespeed Optimierung</label>
109+
<label lang="en">Optimize for Pagespeed</label>
110+
<value>1</value>
111+
<description lang="de"><![CDATA[
112+
Die Aktivierung dieses Feldes kann dazu führen, dass der Google Tag Manager nicht mehr
113+
ordnungsgemäß funktioniert und sollte daher nur von erfahrenden Nutzern durchgeführt werden.
114+
]]></description>
115+
<description lang="en"><![CDATA[
116+
Activation of this field can break the funcionality of Google Tag Manager and should
117+
therefore only be done by experienced users.
118+
]]></description>
105119
</element>
106120
</elements>
107121
</config>

Resources/tags/pagespeed/head.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!-- WbmTagManager -->
2+
<script%s>
3+
var googleTagManagerFunction = function(w,d,s,l,i) {
4+
w[l]=w[l]||[];
5+
w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});
6+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
7+
j.async=true;
8+
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'%s';
9+
f.parentNode.insertBefore(j,f);
10+
};
11+
12+
setTimeout(() => {
13+
googleTagManagerFunction(window,document,'script','dataLayer','%s');
14+
}, 3000);
15+
</script>
16+
<!-- End WbmTagManager -->

Subscriber/Frontend/FilterRender.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ public function includeDataLayerInHead(
126126
$extendedUrlParams = trim($this->pluginConfig('wbmExtendedURLParameter'));
127127
$headTag = '';
128128
if (!$this->pluginConfig('wbmTagManagerCookieConsent')) {
129-
$headTag = file_get_contents($this->pluginDir . '/Resources/tags/head.html');
129+
if($this->pluginConfig('wbmTagManagerPagespeed')){
130+
$headTag = file_get_contents($this->pluginDir . '/Resources/tags/pagespeed/head.html');
131+
} else {
132+
$headTag = file_get_contents($this->pluginDir . '/Resources/tags/head.html');
133+
}
130134
$headTag = sprintf(
131135
$headTag,
132136
(!empty($this->pluginConfig('wbmScriptTagAttributes')) ? ' ' . $this->pluginConfig('wbmScriptTagAttributes') : ''),

plugin.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<label lang="de">Tag Manager</label>
44
<label lang="en">Tag Manager</label>
55

6-
<version>3.5.5</version>
6+
7+
<version>3.5.6</version>
78
<copyright>Webmatch GmbH</copyright>
89
<license>proprietary</license>
910
<link>http://www.webmatch.de</link>
@@ -12,6 +13,11 @@
1213
<author>Webmatch GmbH</author>
1314
<compatibility minVersion="5.6.3" />
1415

16+
<changelog version="3.5.6">
17+
<changes lang="de">Hinzufügen der optionalen Pagespeed-Optimierung</changes>
18+
<changes lang="en">Adding optional Pagespeed Optimisation</changes>
19+
</changelog>
20+
1521
<changelog version="3.5.5">
1622
<changes lang="de">Behebt fehlendes Tracking für removeFromCart auf der Warenkorb-Seite, die Daten sind nicht konfigurierbar im Backend</changes>
1723
<changes lang="en">Fix missing removeFromCart tracking on the cart page, data is not configurable in the backend</changes>

0 commit comments

Comments
 (0)