Version Description
- Added: Automatically add the noscript part of the container code after the opening body tag for WordPress 5.2+ sites where themes support the new wp_body_open action
- Added: add associated taxonomy values for post type
- Added: select brand taxonomy for WooCommerce products to populate "Product brand" dimension in enhanced ecommerce
- Added: add cart content into data layer so that you can personalize your site experience using Google Optimize
- Added: option to remove shipping costs from revenue data on order received page of WooCommerce
- Added: if you enable either enhanced ecommerce or just Google Ads remarketing variables, 3 new data layer variables will be also available about the product on a detail page
- Product rating details (productRatingCounts)
- Averate product rating (productAverageRating)
- Review count (productReviewCount)
- Added: if you are using Cloudflare, you can now add the country code HTTP header value into the data layer and read from it with the geoCloudflareCountryCode variable name
- Fixed: better compatibility with Google's mod_pagespeed
- Fixed: missing product quantity while adding a variable product into the cart
- Fixed: prevent multiple tracking of WooCommerce orders on mobile devices where the mobile browser reloads the order received page from local cache executing GTM tracking again
Download this release
Release Info
Developer | duracelltomi |
Plugin | DuracellTomi's Google Tag Manager for WordPress |
Version | 1.10 |
Comparing to | |
See all releases |
Code changes from version 1.9.2 to 1.10
- admin/admin.php +824 -753
- common/readoptions.php +212 -202
- css/admin-gtm4wp.css +71 -71
- duracelltomi-google-tag-manager-for-wordpress.php +8 -8
- integration/amp.php +45 -36
- integration/google-optimize.php +11 -11
- integration/soundcloud.php +4 -4
- integration/vimeo.php +5 -5
- integration/woocommerce.php +537 -404
- integration/youtube.php +7 -7
- js/admin-subtabs.js +3 -3
- js/admin-tabcreator.js +2 -2
- js/gtm4wp-soundcloud.js +5 -5
- js/gtm4wp-vimeo-froogaloop.js +1 -1
- js/gtm4wp-woocommerce-enhanced.js +63 -56
- public/frontend.php +387 -314
- readme.txt +32 -12
- uninstall.php +3 -3
admin/admin.php
CHANGED
@@ -1,585 +1,628 @@
|
|
1 |
<?php
|
2 |
-
define( 'GTM4WP_ADMINSLUG',
|
3 |
-
define( 'GTM4WP_ADMIN_GROUP',
|
4 |
-
|
5 |
-
define( 'GTM4WP_ADMIN_GROUP_GENERAL',
|
6 |
-
define( 'GTM4WP_ADMIN_GROUP_GTMID',
|
7 |
-
define( 'GTM4WP_ADMIN_GROUP_PLACEMENT',
|
8 |
-
define( 'GTM4WP_ADMIN_GROUP_INFO',
|
9 |
-
|
10 |
-
define( 'GTM4WP_ADMIN_GROUP_INCLUDES',
|
11 |
-
define( 'GTM4WP_ADMIN_GROUP_EVENTS',
|
12 |
-
define( 'GTM4WP_ADMIN_GROUP_SCROLLER',
|
13 |
-
define( 'GTM4WP_ADMIN_GROUP_BLACKLIST',
|
14 |
define( 'GTM4WP_ADMIN_GROUP_INTEGRATION', 'gtm4wp-admin-group-integration' );
|
15 |
-
define( 'GTM4WP_ADMIN_GROUP_ADVANCED',
|
16 |
-
define( 'GTM4WP_ADMIN_GROUP_CREDITS',
|
17 |
|
18 |
define( 'GTM4WP_USER_NOTICES_KEY', 'gtm4wp_user_notices_dismisses' );
|
19 |
|
20 |
-
define( 'GTM4WP_PHASE_STABLE',
|
21 |
-
define( 'GTM4WP_PHASE_BETA',
|
22 |
define( 'GTM4WP_PHASE_EXPERIMENTAL', 'gtm4wp-phase-experimental' );
|
23 |
-
define( 'GTM4WP_PHASE_DEPRECATED',
|
24 |
-
|
25 |
-
$GLOBALS[
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
);
|
33 |
|
34 |
-
$GLOBALS[
|
35 |
-
GTM4WP_OPTION_INCLUDE_POSTTYPE
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
),
|
40 |
-
GTM4WP_OPTION_INCLUDE_CATEGORIES
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
),
|
45 |
-
GTM4WP_OPTION_INCLUDE_TAGS
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
),
|
50 |
-
GTM4WP_OPTION_INCLUDE_AUTHORID
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
),
|
55 |
-
GTM4WP_OPTION_INCLUDE_AUTHOR
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
),
|
60 |
-
GTM4WP_OPTION_INCLUDE_POSTDATE
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
),
|
65 |
-
GTM4WP_OPTION_INCLUDE_POSTTITLE
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
),
|
70 |
-
GTM4WP_OPTION_INCLUDE_POSTCOUNT
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
),
|
75 |
-
GTM4WP_OPTION_INCLUDE_POSTID
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
),
|
80 |
-
GTM4WP_OPTION_INCLUDE_POSTFORMAT
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
),
|
85 |
-
|
86 |
-
"label" => __( "
|
87 |
-
"description" => __( "Check this option to include
|
88 |
-
"phase" => GTM4WP_PHASE_STABLE
|
89 |
-
),
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
),
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
),
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
),
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
),
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
),
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
),
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
),
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
),
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
),
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
),
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
),
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
),
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
),
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
),
|
167 |
-
|
168 |
),
|
169 |
-
GTM4WP_OPTION_INCLUDE_WEATHERUNITS
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
),
|
174 |
GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => array(
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
),
|
179 |
-
GTM4WP_OPTION_INCLUDE_SITEID
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
183 |
),
|
184 |
-
GTM4WP_OPTION_INCLUDE_SITENAME => array(
|
185 |
-
"label" => __( "Site name", 'duracelltomi-google-tag-manager' ),
|
186 |
-
"description" => __( 'Name of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
|
187 |
-
"phase" => GTM4WP_PHASE_STABLE
|
188 |
-
)
|
189 |
);
|
190 |
|
191 |
-
$GLOBALS[
|
192 |
-
GTM4WP_OPTION_EVENTS_FORMMOVE
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
),
|
197 |
-
GTM4WP_OPTION_EVENTS_NEWUSERREG
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
),
|
202 |
-
GTM4WP_OPTION_EVENTS_USERLOGIN
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
),
|
207 |
-
GTM4WP_OPTION_EVENTS_YOUTUBE
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
),
|
212 |
-
GTM4WP_OPTION_EVENTS_VIMEO
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
),
|
217 |
-
GTM4WP_OPTION_EVENTS_SOUNDCLOUD
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
),
|
222 |
-
GTM4WP_OPTION_EVENTS_SOCIAL
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
),
|
227 |
GTM4WP_OPTION_EVENTS_OUTBOUND => array(
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
),
|
232 |
GTM4WP_OPTION_EVENTS_DOWNLOADS => array(
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
),
|
237 |
GTM4WP_OPTION_EVENTS_DWLEXT => array(
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
),
|
242 |
GTM4WP_OPTION_EVENTS_EMAILCLICKS => array(
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
)
|
247 |
);
|
248 |
|
249 |
-
$GLOBALS[
|
250 |
GTM4WP_OPTION_SCROLLER_ENABLED => array(
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
),
|
255 |
GTM4WP_OPTION_SCROLLER_DEBUGMODE => array(
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
),
|
260 |
GTM4WP_OPTION_SCROLLER_CALLBACKTIME => array(
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
),
|
265 |
GTM4WP_OPTION_SCROLLER_DISTANCE => array(
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
),
|
270 |
GTM4WP_OPTION_SCROLLER_CONTENTID => array(
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
),
|
275 |
GTM4WP_OPTION_SCROLLER_READERTIME => array(
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
)
|
280 |
);
|
281 |
|
282 |
-
$GLOBALS[
|
283 |
-
GTM4WP_OPTION_BLACKLIST_ENABLE
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
),
|
288 |
-
GTM4WP_OPTION_BLACKLIST_AWCONV
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
),
|
293 |
-
GTM4WP_OPTION_BLACKLIST_AWREMARKET
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
),
|
298 |
-
GTM4WP_OPTION_BLACKLIST_GACLASSIC
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
),
|
303 |
-
GTM4WP_OPTION_BLACKLIST_UA
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
),
|
308 |
-
GTM4WP_OPTION_BLACKLIST_ADADVISOR
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
),
|
313 |
-
GTM4WP_OPTION_BLACKLIST_ADROLL
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
),
|
318 |
-
GTM4WP_OPTION_BLACKLIST_BIZO
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
),
|
323 |
-
GTM4WP_OPTION_BLACKLIST_CLICKTALE
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
),
|
328 |
-
GTM4WP_OPTION_BLACKLIST_COMSCORE
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
),
|
333 |
-
GTM4WP_OPTION_BLACKLIST_CUSTOMHTML
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
),
|
338 |
-
GTM4WP_OPTION_BLACKLIST_CUSTOMIMG
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
),
|
343 |
-
GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
),
|
348 |
-
GTM4WP_OPTION_BLACKLIST_DBLCLKSALES
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
),
|
353 |
GTM4WP_OPTION_BLACKLIST_MARIN => array(
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
),
|
358 |
-
GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
),
|
363 |
-
GTM4WP_OPTION_BLACKLIST_MPLEXROI
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
),
|
368 |
-
GTM4WP_OPTION_BLACKLIST_MEDIA6DEG
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
),
|
373 |
-
GTM4WP_OPTION_BLACKLIST_TURNCONV
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
377 |
),
|
378 |
-
GTM4WP_OPTION_BLACKLIST_TURNDATA => array(
|
379 |
-
"label" => __( "Turn Data Collection Tag", 'duracelltomi-google-tag-manager' ),
|
380 |
-
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
381 |
-
"phase" => GTM4WP_PHASE_STABLE
|
382 |
-
)
|
383 |
);
|
384 |
|
385 |
-
$GLOBALS[
|
386 |
GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT => array(
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
),
|
391 |
GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS => array(
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
),
|
396 |
GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT => array(
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
),
|
401 |
GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE => array(
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
),
|
406 |
GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME => array(
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
),
|
411 |
GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR => array(
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
),
|
416 |
GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR => array(
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
),
|
421 |
GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM => array(
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
),
|
426 |
GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER => array(
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
),
|
431 |
GTM4WP_OPTION_BLACKLIST_MACRO_URL => array(
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
),
|
436 |
GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT => array(
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
)
|
441 |
);
|
442 |
|
443 |
-
$GLOBALS[
|
444 |
-
GTM4WP_OPTION_INTEGRATE_WPCF7
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
),
|
450 |
-
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
),
|
456 |
-
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
),
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
),
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
),
|
480 |
-
|
481 |
-
"label" => __( "
|
482 |
-
"description" => __( "Enable this to
|
483 |
-
"phase" => GTM4WP_PHASE_BETA,
|
484 |
-
"plugintocheck" => "woocommerce/woocommerce.php"
|
485 |
-
),
|
486 |
-
GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => array(
|
487 |
-
"label" => __( "Product ID prefix", 'duracelltomi-google-tag-manager' ),
|
488 |
-
"description" => __( "Some product feed generator plugins prefix product IDs with a fixed text like 'woocommerce_gpf'. You can enter this prefix here so that tags in your website include this prefix as well.", 'duracelltomi-google-tag-manager' ),
|
489 |
-
"phase" => GTM4WP_PHASE_BETA,
|
490 |
-
"plugintocheck" => "woocommerce/woocommerce.php"
|
491 |
-
),
|
492 |
-
GTM4WP_OPTION_INTEGRATE_WCUSESKU => array(
|
493 |
-
"label" => __( "Use SKU instead of ID", 'duracelltomi-google-tag-manager' ),
|
494 |
-
"description" => __( "Check this to use product SKU instead of the ID of the products for remarketing and ecommerce tracking. Will fallback to ID if no SKU is set.", 'duracelltomi-google-tag-manager' ),
|
495 |
"phase" => GTM4WP_PHASE_BETA,
|
496 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
497 |
),
|
498 |
GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH => array(
|
499 |
-
|
500 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
"phase" => GTM4WP_PHASE_BETA,
|
502 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
503 |
),
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
),
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
|
|
|
|
|
|
520 |
),
|
521 |
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
529 |
),
|
530 |
-
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => array(
|
531 |
-
"label" => __( "Google Optimize page-hiding timeout", 'duracelltomi-google-tag-manager' ),
|
532 |
-
"description" => __( "Enter here the amount of time in milliseconds that the page-hiding snippet should wait before page content gets visible even if Google Optimize has not been completely loaded yet.", 'duracelltomi-google-tag-manager' ),
|
533 |
-
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
534 |
-
),
|
535 |
-
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID => array(
|
536 |
-
"label" => __( "Google Optimize - Google Analytics property ID", 'duracelltomi-google-tag-manager' ),
|
537 |
-
"description" => __( "If you enter your Google Analytics property ID here as well (UA-NNNNNN-N), this plugin will also load your Google Optimize container itself. Leave this blank to only load the page hiding snippet.", 'duracelltomi-google-tag-manager' ) .
|
538 |
-
'<br /><span class="goid_ga_validation_error">' . __( "This does not seems to be a valid Google Analytics property ID! Valid format: UA-NNNNNN-N where N can be numbers. Enter a single property ID here.", 'duracelltomi-google-tag-manager' ) . '</span>',
|
539 |
-
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
540 |
-
),
|
541 |
-
|
542 |
-
GTM4WP_OPTION_INTEGRATE_AMPID => array(
|
543 |
-
"label" => __( "Google Tag Manager 'AMP' Container ID", 'duracelltomi-google-tag-manager' ),
|
544 |
-
"description" => sprintf( __( "Enter a comma separated list of Google Tag Manager container IDs that you would like to use on your site. This plugin will add the <a href=\"%s\">AMP GTM snippet</a> to your AMP pages.", 'duracelltomi-google-tag-manager' ), 'https://support.google.com/tagmanager/answer/6103696?hl=en' ) .
|
545 |
-
'<br /><span class="ampid_validation_error">' . __( "This does not seems to be a valid Google Tag Manager Container ID! Valid format: GTM-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.", 'duracelltomi-google-tag-manager' ) . '</span>',
|
546 |
-
"phase" => GTM4WP_PHASE_EXPERIMENTAL,
|
547 |
-
"plugintocheck" => "amp/amp.php"
|
548 |
-
)
|
549 |
);
|
550 |
|
551 |
-
$GLOBALS[
|
552 |
GTM4WP_OPTION_DATALAYER_NAME => array(
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
),
|
557 |
GTM4WP_OPTION_ENV_GTM_AUTH => array(
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
),
|
562 |
GTM4WP_OPTION_ENV_GTM_PREVIEW => array(
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
),
|
567 |
-
GTM4WP_OPTION_DONOTTRACK
|
568 |
-
|
569 |
-
|
570 |
-
|
|
|
|
|
|
|
|
|
|
|
571 |
),
|
572 |
-
GTM4WP_OPTION_LOADEARLY => array(
|
573 |
-
"label" => __( "Load GTM container as early as possible", 'duracelltomi-google-tag-manager' ),
|
574 |
-
"description" => __( "Turning on this option will load your Google Tag Manager container as early as possible during page load. This can cause issues if you are using jQuery in your custom HTML tags that fire on 'Page View' events.", 'duracelltomi-google-tag-manager' ),
|
575 |
-
"phase" => GTM4WP_PHASE_STABLE
|
576 |
-
)
|
577 |
);
|
578 |
|
579 |
function gtm4wp_admin_output_section( $args ) {
|
580 |
echo '<span class="tabinfo">';
|
581 |
|
582 |
-
switch( $args[
|
583 |
case GTM4WP_ADMIN_GROUP_GENERAL: {
|
584 |
_e( 'This plugin is intended to be used by IT girls&guys and marketing staff. Please be sure you read the <a href="https://developers.google.com/tag-manager/" target="_blank">Google Tag Manager Help Center</a> before you start using this plugin.<br /><br />', 'duracelltomi-google-tag-manager' );
|
585 |
|
@@ -587,11 +630,11 @@ function gtm4wp_admin_output_section( $args ) {
|
|
587 |
}
|
588 |
|
589 |
case GTM4WP_ADMIN_GROUP_INCLUDES: {
|
590 |
-
_e(
|
591 |
-
echo
|
592 |
-
printf( __( '* Browser, OS and Device data is provided using <a href="%s">WhichBrowser</a> library.', 'duracelltomi-google-tag-manager' ),
|
593 |
if ( version_compare( PHP_VERSION, '5.4.0' ) < 0 ) {
|
594 |
-
echo
|
595 |
_e( 'You are using an <strong>outdated</strong> version of PHP (v' . PHP_VERSION . '). You <strong>should not turn on</strong> browser/device/os tracking as this can hurt your site. Please talk to your hosting and upgrade to PHP 5.4 or newer.', 'duracelltomi-google-tag-manager' );
|
596 |
}
|
597 |
|
@@ -599,7 +642,7 @@ function gtm4wp_admin_output_section( $args ) {
|
|
599 |
}
|
600 |
|
601 |
case GTM4WP_ADMIN_GROUP_EVENTS: {
|
602 |
-
_e(
|
603 |
echo '<p style="font-weight: bold;">';
|
604 |
_e( 'In October 2013 Google released a new feature called <a href="https://support.google.com/tagmanager/answer/3415369?hl=en" target="_blank">auto event tracking</a>. It is up to you how you use click events either using Google\'s solution or the settings below.', 'duracelltomi-google-tag-manager' );
|
605 |
echo '</p>';
|
@@ -608,39 +651,39 @@ function gtm4wp_admin_output_section( $args ) {
|
|
608 |
}
|
609 |
|
610 |
case GTM4WP_ADMIN_GROUP_SCROLLER: {
|
611 |
-
_e(
|
612 |
echo '<br />';
|
613 |
-
printf( __( 'Based on the script originaly posted to <a href="%s">Analytics Talk</a>', 'duracelltomi-google-tag-manager' )
|
614 |
|
615 |
break;
|
616 |
}
|
617 |
|
618 |
case GTM4WP_ADMIN_GROUP_BLACKLIST: {
|
619 |
-
_e(
|
620 |
echo '<br />';
|
621 |
-
_e(
|
622 |
echo '<br />';
|
623 |
-
_e(
|
624 |
echo '<br />';
|
625 |
-
_e(
|
626 |
|
627 |
break;
|
628 |
}
|
629 |
|
630 |
case GTM4WP_ADMIN_GROUP_INTEGRATION: {
|
631 |
-
_e(
|
632 |
|
633 |
break;
|
634 |
}
|
635 |
|
636 |
case GTM4WP_ADMIN_GROUP_ADVANCED: {
|
637 |
-
_e(
|
638 |
|
639 |
break;
|
640 |
}
|
641 |
|
642 |
case GTM4WP_ADMIN_GROUP_CREDITS: {
|
643 |
-
_e(
|
644 |
|
645 |
break;
|
646 |
}
|
@@ -652,98 +695,117 @@ function gtm4wp_admin_output_section( $args ) {
|
|
652 |
function gtm4wp_admin_output_field( $args ) {
|
653 |
global $gtm4wp_options;
|
654 |
|
655 |
-
switch( $args[
|
656 |
case GTM4WP_ADMIN_GROUP_GTMID: {
|
657 |
-
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" value="' . $gtm4wp_options[GTM4WP_OPTION_GTM_CODE] . '" /><br />' . $args[
|
658 |
-
echo '<br /><span class="gtmid_validation_error">' . __(
|
659 |
|
660 |
break;
|
661 |
}
|
662 |
|
663 |
case GTM4WP_ADMIN_GROUP_PLACEMENT: {
|
664 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_FOOTER . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_FOOTER . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_FOOTER ? 'checked="checked"' : '' ) . '/> ' . __(
|
665 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_BODYOPEN . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_BODYOPEN . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN ? 'checked="checked"' : '' ) . '/> ' . __(
|
666 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN_AUTO ? 'checked="checked"' : '' ) . '/> ' . __(
|
667 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_OFF . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_OFF . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __(
|
668 |
|
669 |
break;
|
670 |
}
|
671 |
|
672 |
-
case GTM4WP_OPTIONS .
|
673 |
-
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" value="' . $gtm4wp_options[GTM4WP_OPTION_DATALAYER_NAME] . '" /><br />' . $args[
|
674 |
-
echo '<br /><span class="datalayername_validation_error">' . __(
|
675 |
|
676 |
break;
|
677 |
}
|
678 |
|
679 |
-
case GTM4WP_OPTIONS .
|
680 |
-
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" value="' . $gtm4wp_options[GTM4WP_OPTION_ENV_GTM_AUTH] . '" /><br />' . $args[
|
681 |
-
echo '<br /><span class="gtmauth_validation_error">' . __(
|
682 |
|
683 |
break;
|
684 |
}
|
685 |
|
686 |
-
case GTM4WP_OPTIONS .
|
687 |
-
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" value="' . $gtm4wp_options[GTM4WP_OPTION_ENV_GTM_PREVIEW] . '" /><br />' . $args[
|
688 |
-
echo '<br /><span class="gtmpreview_validation_error">' . __(
|
689 |
|
690 |
break;
|
691 |
}
|
692 |
|
693 |
-
case GTM4WP_OPTIONS .
|
694 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="0" ' . ( $gtm4wp_options[GTM4WP_OPTION_BLACKLIST_ENABLE] == 0 ? 'checked="checked"' : '' ) . '/> ' . __(
|
695 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="1" ' . ( $gtm4wp_options[GTM4WP_OPTION_BLACKLIST_ENABLE] == 1 ? 'checked="checked"' : '' ) . '/> ' . __(
|
696 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_2" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="2" ' . ( $gtm4wp_options[GTM4WP_OPTION_BLACKLIST_ENABLE] == 2 ? 'checked="checked"' : '' ) . '/> ' . __(
|
697 |
-
echo $args[
|
698 |
|
699 |
break;
|
700 |
}
|
701 |
|
702 |
-
case GTM4WP_OPTIONS .
|
703 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="0" ' . ( $gtm4wp_options[GTM4WP_OPTION_INCLUDE_WEATHERUNITS] == 0 ? 'checked="checked"' : '' ) . '/> ' . __(
|
704 |
-
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="1" ' . ( $gtm4wp_options[GTM4WP_OPTION_INCLUDE_WEATHERUNITS] == 1 ? 'checked="checked"' : '' ) . '/> ' . __(
|
705 |
-
echo $args[
|
706 |
|
707 |
break;
|
708 |
}
|
709 |
|
710 |
case GTM4WP_ADMIN_GROUP_INFO: {
|
711 |
-
echo $args[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
712 |
|
713 |
break;
|
714 |
}
|
715 |
|
716 |
default: {
|
717 |
-
$optval = $gtm4wp_options[$args[
|
718 |
|
719 |
// fix wrong data type saved in v0.4
|
720 |
-
if ( GTM4WP_OPTION_EVENTS_SOCIAL == $args[
|
721 |
-
$optval = (
|
722 |
}
|
723 |
|
724 |
-
switch( gettype( $optval ) ) {
|
725 |
-
case
|
726 |
-
echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args[
|
727 |
|
728 |
-
if ( isset( $args[
|
729 |
-
if ( is_plugin_active( $args[
|
730 |
-
echo
|
731 |
} else {
|
732 |
-
echo
|
733 |
}
|
734 |
}
|
735 |
|
736 |
break;
|
737 |
}
|
738 |
|
739 |
-
case
|
740 |
-
echo '<input type="number" step="1" min="0" class="small-text" id="' . GTM4WP_OPTIONS . '[' . $args[
|
741 |
|
742 |
-
if ( isset( $args[
|
743 |
-
if ( is_plugin_active( $args[
|
744 |
-
echo
|
745 |
} else {
|
746 |
-
echo
|
747 |
}
|
748 |
}
|
749 |
|
@@ -751,13 +813,13 @@ function gtm4wp_admin_output_field( $args ) {
|
|
751 |
}
|
752 |
|
753 |
default : {
|
754 |
-
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . $args[
|
755 |
|
756 |
-
if ( isset( $args[
|
757 |
-
if ( is_plugin_active( $args[
|
758 |
-
echo
|
759 |
} else {
|
760 |
-
echo
|
761 |
}
|
762 |
}
|
763 |
}
|
@@ -766,32 +828,32 @@ function gtm4wp_admin_output_field( $args ) {
|
|
766 |
} // end switch
|
767 |
}
|
768 |
|
769 |
-
function gtm4wp_sanitize_options($options) {
|
770 |
global $wpdb;
|
771 |
|
772 |
$output = gtm4wp_reload_options();
|
773 |
|
774 |
-
foreach($output as $optionname => $optionvalue) {
|
775 |
-
if ( isset( $options[$optionname] ) ) {
|
776 |
-
$newoptionvalue = $options[$optionname];
|
777 |
} else {
|
778 |
-
$newoptionvalue =
|
779 |
}
|
780 |
|
781 |
// "include" settings
|
782 |
-
if ( substr($optionname, 0, 8) ==
|
783 |
-
$output[$optionname] = (
|
784 |
|
785 |
-
|
786 |
-
}
|
787 |
-
$output[$optionname] = str_replace(
|
788 |
|
789 |
-
|
790 |
-
}
|
791 |
-
$output[$optionname] = (
|
792 |
|
793 |
// clear oembed transients when feature is enabled because we need to hook into the oembed process to enable some 3rd party APIs
|
794 |
-
if ( $output[$optionname] &&
|
795 |
if ( GTM4WP_OPTION_EVENTS_YOUTUBE == $optionname ) {
|
796 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%youtube.com%' AND meta_key LIKE '_oembed_%'" );
|
797 |
}
|
@@ -801,137 +863,137 @@ function gtm4wp_sanitize_options($options) {
|
|
801 |
}
|
802 |
}
|
803 |
|
804 |
-
|
805 |
-
}
|
806 |
-
$_goid_val
|
807 |
-
if (
|
808 |
$_goid_list = array();
|
809 |
} else {
|
810 |
-
$_goid_list = explode(
|
811 |
}
|
812 |
$_goid_haserror = false;
|
813 |
|
814 |
-
foreach( $_goid_list as $one_go_id ) {
|
815 |
-
$_goid_haserror = $_goid_haserror || !preg_match(
|
816 |
}
|
817 |
|
818 |
-
if ( $_goid_haserror && (count($_goid_list) > 0) ) {
|
819 |
-
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __(
|
820 |
} else {
|
821 |
-
$output[$optionname] = $newoptionvalue;
|
822 |
}
|
823 |
-
|
824 |
-
|
825 |
-
$_gaid_val
|
826 |
-
if ( "" == $_gaid_val ) {
|
827 |
$_gaid_list = array();
|
828 |
} else {
|
829 |
-
$_gaid_list = explode(
|
830 |
}
|
831 |
$_gaid_haserror = false;
|
832 |
|
833 |
-
foreach( $_gaid_list as $one_ga_id ) {
|
834 |
-
$_gaid_haserror = $_gaid_haserror || !preg_match(
|
835 |
}
|
836 |
|
837 |
-
if ( $_gaid_haserror && (count($_gaid_list) > 0) ) {
|
838 |
-
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __(
|
839 |
} else {
|
840 |
-
$output[$optionname] = $newoptionvalue;
|
841 |
}
|
|
|
|
|
842 |
|
843 |
-
}
|
844 |
-
$output[$optionname] = (int) $newoptionvalue;
|
845 |
|
846 |
-
}
|
847 |
-
$output[$optionname] = (
|
848 |
|
849 |
-
} else if ( $optionname ==
|
850 |
$output[$optionname] = trim( (string) $newoptionvalue );
|
851 |
|
852 |
-
|
853 |
-
}
|
854 |
-
$_ampid_val
|
855 |
-
if (
|
856 |
$_ampid_list = array();
|
857 |
} else {
|
858 |
-
$_ampid_list = explode(
|
859 |
}
|
860 |
$_ampid_haserror = false;
|
861 |
|
862 |
-
foreach( $_ampid_list as $one_amp_id ) {
|
863 |
-
$_ampid_haserror = $_ampid_haserror || !preg_match(
|
864 |
}
|
865 |
|
866 |
-
if ( $_ampid_haserror && (count($_ampid_list) > 0) ) {
|
867 |
-
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_AMPID . ']', __(
|
868 |
} else {
|
869 |
-
$output[$optionname] = $newoptionvalue;
|
870 |
}
|
871 |
|
|
|
|
|
|
|
872 |
|
873 |
-
|
874 |
-
}
|
875 |
-
$
|
876 |
-
|
877 |
-
// GTM code or dataLayer variable name
|
878 |
-
} else if ( ( $optionname == GTM4WP_OPTION_GTM_CODE ) || ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) ) {
|
879 |
-
$newoptionvalue = trim($newoptionvalue);
|
880 |
|
881 |
if ( $optionname == GTM4WP_OPTION_GTM_CODE ) {
|
882 |
-
$_gtmid_list
|
883 |
$_gtmid_haserror = false;
|
884 |
|
885 |
-
foreach( $_gtmid_list as $one_gtm_id ) {
|
886 |
-
|
887 |
}
|
888 |
|
889 |
if ( $_gtmid_haserror ) {
|
890 |
-
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']', __(
|
891 |
} else {
|
892 |
-
$output[$optionname] = $newoptionvalue;
|
893 |
}
|
894 |
-
}
|
895 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']', __( "Invalid dataLayer variable name. Please start with a character from a-z or A-Z followed by characters from a-z, A-Z, 0-9 or '_' or '-'!", 'duracelltomi-google-tag-manager' ) );
|
896 |
|
897 |
-
}
|
898 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']', __( "Invalid gtm_auth environment parameter value. It should only contain letters, numbers or the '-' and '_' characters.", 'duracelltomi-google-tag-manager' ) );
|
899 |
|
900 |
-
}
|
901 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']', __( "Invalid gtm_preview environment parameter value. It should have the format 'env-NN' where NN is an integer number.", 'duracelltomi-google-tag-manager' ) );
|
902 |
|
903 |
} else {
|
904 |
-
$output[$optionname] = $newoptionvalue;
|
905 |
}
|
906 |
|
907 |
-
|
908 |
-
}
|
909 |
-
$output[$optionname] = (int) $newoptionvalue;
|
910 |
-
if ( ( $output[$optionname] < 0) || ( $output[$optionname] > 3 ) ) {
|
911 |
-
$output[$optionname] = 0;
|
912 |
}
|
913 |
|
914 |
-
|
915 |
-
}
|
916 |
-
$output[$optionname] = trim( str_replace(
|
917 |
|
918 |
-
|
919 |
} else {
|
920 |
-
switch( gettype($optionvalue)) {
|
921 |
-
case
|
922 |
-
$output[$optionname] = (
|
923 |
|
924 |
break;
|
925 |
}
|
926 |
|
927 |
-
case
|
928 |
-
$output[$optionname] = (int) $newoptionvalue;
|
929 |
|
930 |
break;
|
931 |
}
|
932 |
|
933 |
default: {
|
934 |
-
$output[$optionname] = $newoptionvalue;
|
935 |
}
|
936 |
} // end switch
|
937 |
}
|
@@ -944,7 +1006,7 @@ function gtm4wp_admin_init() {
|
|
944 |
global $gtm4wp_includefieldtexts, $gtm4wp_eventfieldtexts, $gtm4wp_integratefieldtexts, $gtm4wp_scrollerfieldtexts,
|
945 |
$gtm4wp_blacklistfieldtexts, $gtm4wp_blacklistmfieldtexts, $gtm4wp_advancedfieldtexts;
|
946 |
|
947 |
-
register_setting( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS,
|
948 |
|
949 |
add_settings_section(
|
950 |
GTM4WP_ADMIN_GROUP_GENERAL,
|
@@ -960,8 +1022,8 @@ function gtm4wp_admin_init() {
|
|
960 |
GTM4WP_ADMINSLUG,
|
961 |
GTM4WP_ADMIN_GROUP_GENERAL,
|
962 |
array(
|
963 |
-
|
964 |
-
|
965 |
)
|
966 |
);
|
967 |
|
@@ -972,9 +1034,9 @@ function gtm4wp_admin_init() {
|
|
972 |
GTM4WP_ADMINSLUG,
|
973 |
GTM4WP_ADMIN_GROUP_GENERAL,
|
974 |
array(
|
975 |
-
|
976 |
-
//
|
977 |
-
|
978 |
)
|
979 |
);
|
980 |
|
@@ -985,17 +1047,17 @@ function gtm4wp_admin_init() {
|
|
985 |
GTM4WP_ADMINSLUG
|
986 |
);
|
987 |
|
988 |
-
foreach($gtm4wp_includefieldtexts as $fieldid => $fielddata) {
|
989 |
add_settings_field(
|
990 |
-
|
991 |
-
$fielddata[
|
992 |
'gtm4wp_admin_output_field',
|
993 |
GTM4WP_ADMINSLUG,
|
994 |
GTM4WP_ADMIN_GROUP_INCLUDES,
|
995 |
array(
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
)
|
1000 |
);
|
1001 |
}
|
@@ -1007,17 +1069,17 @@ function gtm4wp_admin_init() {
|
|
1007 |
GTM4WP_ADMINSLUG
|
1008 |
);
|
1009 |
|
1010 |
-
foreach($gtm4wp_eventfieldtexts as $fieldid => $fielddata) {
|
1011 |
add_settings_field(
|
1012 |
-
|
1013 |
-
$fielddata[
|
1014 |
'gtm4wp_admin_output_field',
|
1015 |
GTM4WP_ADMINSLUG,
|
1016 |
GTM4WP_ADMIN_GROUP_EVENTS,
|
1017 |
array(
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
)
|
1022 |
);
|
1023 |
}
|
@@ -1029,17 +1091,17 @@ function gtm4wp_admin_init() {
|
|
1029 |
GTM4WP_ADMINSLUG
|
1030 |
);
|
1031 |
|
1032 |
-
foreach($gtm4wp_scrollerfieldtexts as $fieldid => $fielddata) {
|
1033 |
add_settings_field(
|
1034 |
-
|
1035 |
-
$fielddata[
|
1036 |
'gtm4wp_admin_output_field',
|
1037 |
GTM4WP_ADMINSLUG,
|
1038 |
GTM4WP_ADMIN_GROUP_SCROLLER,
|
1039 |
array(
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
)
|
1044 |
);
|
1045 |
}
|
@@ -1051,32 +1113,32 @@ function gtm4wp_admin_init() {
|
|
1051 |
GTM4WP_ADMINSLUG
|
1052 |
);
|
1053 |
|
1054 |
-
foreach($gtm4wp_blacklistfieldtexts as $fieldid => $fielddata) {
|
1055 |
add_settings_field(
|
1056 |
-
|
1057 |
-
$fielddata[
|
1058 |
'gtm4wp_admin_output_field',
|
1059 |
GTM4WP_ADMINSLUG,
|
1060 |
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1061 |
array(
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
)
|
1066 |
);
|
1067 |
}
|
1068 |
|
1069 |
-
foreach($gtm4wp_blacklistmfieldtexts as $fieldid => $fielddata) {
|
1070 |
add_settings_field(
|
1071 |
-
|
1072 |
-
$fielddata[
|
1073 |
'gtm4wp_admin_output_field',
|
1074 |
GTM4WP_ADMINSLUG,
|
1075 |
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1076 |
array(
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
)
|
1081 |
);
|
1082 |
}
|
@@ -1088,18 +1150,18 @@ function gtm4wp_admin_init() {
|
|
1088 |
GTM4WP_ADMINSLUG
|
1089 |
);
|
1090 |
|
1091 |
-
foreach($gtm4wp_integratefieldtexts as $fieldid => $fielddata) {
|
1092 |
add_settings_field(
|
1093 |
-
|
1094 |
-
$fielddata[
|
1095 |
'gtm4wp_admin_output_field',
|
1096 |
GTM4WP_ADMINSLUG,
|
1097 |
GTM4WP_ADMIN_GROUP_INTEGRATION,
|
1098 |
array(
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
)
|
1104 |
);
|
1105 |
}
|
@@ -1111,18 +1173,18 @@ function gtm4wp_admin_init() {
|
|
1111 |
GTM4WP_ADMINSLUG
|
1112 |
);
|
1113 |
|
1114 |
-
foreach($gtm4wp_advancedfieldtexts as $fieldid => $fielddata) {
|
1115 |
add_settings_field(
|
1116 |
-
|
1117 |
-
$fielddata[
|
1118 |
'gtm4wp_admin_output_field',
|
1119 |
GTM4WP_ADMINSLUG,
|
1120 |
GTM4WP_ADMIN_GROUP_ADVANCED,
|
1121 |
array(
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
)
|
1127 |
);
|
1128 |
}
|
@@ -1141,35 +1203,35 @@ function gtm4wp_admin_init() {
|
|
1141 |
GTM4WP_ADMINSLUG,
|
1142 |
GTM4WP_ADMIN_GROUP_CREDITS,
|
1143 |
array(
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
)
|
1150 |
);
|
1151 |
|
1152 |
// apply oembed code changes on the admin as well since the oembed call on the admin is cached by WordPress into a transient
|
1153 |
// that is applied on the frontend later
|
1154 |
-
require_once
|
1155 |
-
require_once
|
1156 |
-
require_once
|
1157 |
}
|
1158 |
|
1159 |
function gtm4wp_show_admin_page() {
|
1160 |
global $gtp4wp_plugin_url;
|
1161 |
-
?>
|
1162 |
<div class="wrap">
|
1163 |
<div id="gtm4wp-icon" class="icon32" style="background-image: url(<?php echo $gtp4wp_plugin_url; ?>admin/images/tag_manager-32.png);"><br /></div>
|
1164 |
<h2><?php _e( 'Google Tag Manager for WordPress options', 'duracelltomi-google-tag-manager' ); ?></h2>
|
1165 |
<form action="options.php" method="post">
|
1166 |
-
<?php settings_fields( GTM4WP_ADMIN_GROUP ); ?>
|
1167 |
-
<?php do_settings_sections( GTM4WP_ADMINSLUG ); ?>
|
1168 |
-
<?php submit_button(); ?>
|
1169 |
|
1170 |
</form>
|
1171 |
</div>
|
1172 |
-
<?php
|
1173 |
}
|
1174 |
|
1175 |
function gtm4wp_add_admin_page() {
|
@@ -1182,37 +1244,37 @@ function gtm4wp_add_admin_page() {
|
|
1182 |
);
|
1183 |
}
|
1184 |
|
1185 |
-
function gtm4wp_add_admin_js($hook) {
|
1186 |
global $gtp4wp_plugin_url;
|
1187 |
|
1188 |
-
if ( $hook ==
|
1189 |
-
wp_register_script(
|
1190 |
|
1191 |
$subtabtexts = array(
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
);
|
1210 |
-
wp_localize_script(
|
1211 |
|
1212 |
-
wp_enqueue_script(
|
1213 |
-
wp_enqueue_script(
|
1214 |
|
1215 |
-
wp_enqueue_style(
|
1216 |
}
|
1217 |
}
|
1218 |
|
@@ -1390,78 +1452,82 @@ function gtm4wp_show_warning() {
|
|
1390 |
global $gtm4wp_options, $gtp4wp_plugin_url, $gtm4wp_integratefieldtexts, $current_user,
|
1391 |
$gtm4wp_def_user_notices_dismisses;
|
1392 |
|
1393 |
-
$woo_plugin_active = is_plugin_active( $gtm4wp_integratefieldtexts[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ][
|
1394 |
-
if ( $woo_plugin_active ) {
|
1395 |
$woo = WC();
|
1396 |
} else {
|
1397 |
-
$woo =
|
1398 |
}
|
1399 |
|
1400 |
$gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
|
1401 |
-
if ( $gtm4wp_user_notices_dismisses ===
|
1402 |
-
|
|
|
|
|
|
|
|
|
1403 |
} else {
|
1404 |
$gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
|
1405 |
-
if ( false === $gtm4wp_user_notices_dismisses ) {
|
1406 |
$gtm4wp_user_notices_dismisses = array();
|
1407 |
}
|
1408 |
}
|
1409 |
$gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
|
1410 |
|
1411 |
-
if ( ( trim( $gtm4wp_options[GTM4WP_OPTION_GTM_CODE] ) ==
|
1412 |
-
echo '<div class="gtm4wp-notice notice notice-error is-dismissible" data-href="?enter-gtm-code"><p><strong>' . sprintf( __( 'To start using Google Tag Manager for WordPress, please <a href="%s">enter your GTM ID</a>', 'duracelltomi-google-tag-manager' ),
|
1413 |
}
|
1414 |
|
1415 |
-
if ((
|
1416 |
-
(
|
1417 |
) || (
|
1418 |
-
(
|
1419 |
-
)) {
|
1420 |
-
echo '<div class="gtm4wp-notice notice notice-error" data-href="?incomplete-gtm-env-config"><p><strong>' . sprintf( __( 'Incomplete Google Tag Manager environment configuration: either gtm_preview or gtm_auth parameter value is missing!', 'duracelltomi-google-tag-manager' ),
|
1421 |
}
|
1422 |
|
1423 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1424 |
$is_wc_active = $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ||
|
1425 |
$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ||
|
1426 |
$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ];
|
1427 |
|
1428 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1429 |
-
$woo_ga_options = get_option(
|
1430 |
if ( $woo_ga_options ) {
|
1431 |
-
if (
|
1432 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-ga-plugin-warning"><p><strong>' . __( 'Notice: you should disable Google Analytics tracking <a href="admin.php?page=wc-settings&tab=integration§ion=google_analytics">in WooCommerce settings</a> by leaving Google Analytics ID field empty if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1433 |
}
|
1434 |
}
|
1435 |
}
|
1436 |
|
1437 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1438 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-ga-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "WooCommerce Google Analytics Integration" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1439 |
}
|
1440 |
|
1441 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1442 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-gayoast-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "Google Analytics for WordPress by MonsterInsights" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1443 |
}
|
1444 |
}
|
1445 |
|
1446 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1447 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?php56-warning"><p><strong>' . __( 'Warning: You are using an outdated version of PHP (v' . PHP_VERSION . ') that can cause issues with the plugin Google Tag Manager for WordPress. Please consider to upgrade your PHP.', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1448 |
}
|
1449 |
|
1450 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1451 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?woo2x-warning"><p><strong>' . __( 'Warning: You are using an outdated version of WooCommerce (v' . $woo->version . '). Google Tag Manager for WordPress will drop support for this version in the near future. Please consider to upgrade.', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1452 |
}
|
1453 |
|
1454 |
-
if ( ( false === $gtm4wp_user_notices_dismisses[
|
1455 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOCIAL ] ) ||
|
1456 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) ||
|
1457 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) ||
|
1458 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] )
|
1459 |
-
)) {
|
1460 |
$deprecated_list = array(
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
);
|
1466 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?deprecated-warning"><p><strong>' . __( 'Warning: Some features of Google Tag Manager for WordPress are deprecated and will be removed in the next version: <ul><li>' . implode( '</li><li>', $deprecated_list ) . '</li></ul>', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1467 |
}
|
@@ -1471,17 +1537,21 @@ function gtm4wp_dismiss_notice() {
|
|
1471 |
global $gtm4wp_def_user_notices_dismisses, $current_user;
|
1472 |
|
1473 |
$gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
|
1474 |
-
if ( $gtm4wp_user_notices_dismisses ===
|
1475 |
-
|
|
|
|
|
|
|
|
|
1476 |
} else {
|
1477 |
$gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
|
1478 |
-
if ( false === $gtm4wp_user_notices_dismisses ) {
|
1479 |
$gtm4wp_user_notices_dismisses = array();
|
1480 |
}
|
1481 |
}
|
1482 |
$gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
|
1483 |
|
1484 |
-
$noticeid = trim( basename( $_POST[
|
1485 |
if ( array_key_exists( $noticeid, $gtm4wp_user_notices_dismisses ) ) {
|
1486 |
$gtm4wp_user_notices_dismisses[ $noticeid ] = true;
|
1487 |
update_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, serialize( $gtm4wp_user_notices_dismisses ) );
|
@@ -1491,8 +1561,9 @@ function gtm4wp_dismiss_notice() {
|
|
1491 |
function gtm4wp_add_plugin_action_links( $links, $file ) {
|
1492 |
global $gtp4wp_plugin_basename;
|
1493 |
|
1494 |
-
if ( $file != $gtp4wp_plugin_basename )
|
1495 |
-
|
|
|
1496 |
|
1497 |
$settings_link = '<a href="' . menu_page_url( GTM4WP_ADMINSLUG, false ) . '">' . esc_html( __( 'Settings' ) ) . '</a>';
|
1498 |
|
@@ -1504,7 +1575,7 @@ function gtm4wp_add_plugin_action_links( $links, $file ) {
|
|
1504 |
function gtm4wp_show_upgrade_notification( $current_plugin_metadata, $new_plugin_metadata ) {
|
1505 |
if ( isset( $new_plugin_metadata->upgrade_notice ) && strlen( trim( $new_plugin_metadata->upgrade_notice ) ) > 0 ) {
|
1506 |
echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>Important Upgrade Notice:</strong> ';
|
1507 |
-
echo esc_html($new_plugin_metadata->upgrade_notice), '</p>';
|
1508 |
}
|
1509 |
}
|
1510 |
|
@@ -1515,4 +1586,4 @@ add_action( 'admin_notices', 'gtm4wp_show_warning' );
|
|
1515 |
add_action( 'admin_head', 'gtm4wp_admin_head' );
|
1516 |
add_filter( 'plugin_action_links', 'gtm4wp_add_plugin_action_links', 10, 2 );
|
1517 |
add_action( 'wp_ajax_gtm4wp_dismiss_notice', 'gtm4wp_dismiss_notice' );
|
1518 |
-
add_action( 'in_plugin_update_message-duracelltomi-google-tag-manager-for-wordpress/duracelltomi-google-tag-manager-for-wordpress.php', 'gtm4wp_show_upgrade_notification', 10, 2 );
|
1 |
<?php
|
2 |
+
define( 'GTM4WP_ADMINSLUG', 'gtm4wp-settings' );
|
3 |
+
define( 'GTM4WP_ADMIN_GROUP', 'gtm4wp-admin-group' );
|
4 |
+
|
5 |
+
define( 'GTM4WP_ADMIN_GROUP_GENERAL', 'gtm4wp-admin-group-general' );
|
6 |
+
define( 'GTM4WP_ADMIN_GROUP_GTMID', 'gtm4wp-admin-group-gtm-id' );
|
7 |
+
define( 'GTM4WP_ADMIN_GROUP_PLACEMENT', 'gtm4wp-admin-code-placement' );
|
8 |
+
define( 'GTM4WP_ADMIN_GROUP_INFO', 'gtm4wp-admin-group-datalayer-info' );
|
9 |
+
|
10 |
+
define( 'GTM4WP_ADMIN_GROUP_INCLUDES', 'gtm4wp-admin-group-includes' );
|
11 |
+
define( 'GTM4WP_ADMIN_GROUP_EVENTS', 'gtm4wp-admin-group-events' );
|
12 |
+
define( 'GTM4WP_ADMIN_GROUP_SCROLLER', 'gtm4wp-admin-group-scroller' );
|
13 |
+
define( 'GTM4WP_ADMIN_GROUP_BLACKLIST', 'gtm4wp-admin-group-blacklist-tags' );
|
14 |
define( 'GTM4WP_ADMIN_GROUP_INTEGRATION', 'gtm4wp-admin-group-integration' );
|
15 |
+
define( 'GTM4WP_ADMIN_GROUP_ADVANCED', 'gtm4wp-admin-group-advanced' );
|
16 |
+
define( 'GTM4WP_ADMIN_GROUP_CREDITS', 'gtm4wp-admin-group-credits' );
|
17 |
|
18 |
define( 'GTM4WP_USER_NOTICES_KEY', 'gtm4wp_user_notices_dismisses' );
|
19 |
|
20 |
+
define( 'GTM4WP_PHASE_STABLE', 'gtm4wp-phase-stable' );
|
21 |
+
define( 'GTM4WP_PHASE_BETA', 'gtm4wp-phase-beta' );
|
22 |
define( 'GTM4WP_PHASE_EXPERIMENTAL', 'gtm4wp-phase-experimental' );
|
23 |
+
define( 'GTM4WP_PHASE_DEPRECATED', 'gtm4wp-phase-deprecated' );
|
24 |
+
|
25 |
+
$GLOBALS['gtm4wp_def_user_notices_dismisses'] = array(
|
26 |
+
'enter-gtm-code' => false,
|
27 |
+
'wc-ga-plugin-warning' => false,
|
28 |
+
'wc-gayoast-plugin-warning' => false,
|
29 |
+
'php56-warning' => false,
|
30 |
+
'woo2x-warning' => false,
|
31 |
+
'deprecated-warning' => false,
|
32 |
);
|
33 |
|
34 |
+
$GLOBALS['gtm4wp_includefieldtexts'] = array(
|
35 |
+
GTM4WP_OPTION_INCLUDE_POSTTYPE => array(
|
36 |
+
'label' => __( 'Posttype of current post/archive', 'duracelltomi-google-tag-manager' ),
|
37 |
+
'description' => __( 'Check this option to include the type of the current post or archive page (post, page or any custom post type).', 'duracelltomi-google-tag-manager' ),
|
38 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
39 |
+
),
|
40 |
+
GTM4WP_OPTION_INCLUDE_CATEGORIES => array(
|
41 |
+
'label' => __( 'Category list of current post/archive', 'duracelltomi-google-tag-manager' ),
|
42 |
+
'description' => __( 'Check this option to include the category names of the current post or archive page', 'duracelltomi-google-tag-manager' ),
|
43 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
44 |
+
),
|
45 |
+
GTM4WP_OPTION_INCLUDE_TAGS => array(
|
46 |
+
'label' => __( 'Tags of current post', 'duracelltomi-google-tag-manager' ),
|
47 |
+
'description' => __( 'Check this option to include the tags of the current post.', 'duracelltomi-google-tag-manager' ),
|
48 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
49 |
+
),
|
50 |
+
GTM4WP_OPTION_INCLUDE_AUTHORID => array(
|
51 |
+
'label' => __( 'Post author ID', 'duracelltomi-google-tag-manager' ),
|
52 |
+
'description' => __( 'Check this option to include the ID of the author on the current post or author page.', 'duracelltomi-google-tag-manager' ),
|
53 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
54 |
+
),
|
55 |
+
GTM4WP_OPTION_INCLUDE_AUTHOR => array(
|
56 |
+
'label' => __( 'Post author name', 'duracelltomi-google-tag-manager' ),
|
57 |
+
'description' => __( 'Check this option to include the name of the author on the current post or author page.', 'duracelltomi-google-tag-manager' ),
|
58 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
59 |
+
),
|
60 |
+
GTM4WP_OPTION_INCLUDE_POSTDATE => array(
|
61 |
+
'label' => __( 'Post date', 'duracelltomi-google-tag-manager' ),
|
62 |
+
'description' => __( 'Check this option to include the date of the current post. This will include 4 dataLayer variables: full date, post year, post month, post date.', 'duracelltomi-google-tag-manager' ),
|
63 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
64 |
+
),
|
65 |
+
GTM4WP_OPTION_INCLUDE_POSTTITLE => array(
|
66 |
+
'label' => __( 'Post title', 'duracelltomi-google-tag-manager' ),
|
67 |
+
'description' => __( 'Check this option to include the title of the current post.', 'duracelltomi-google-tag-manager' ),
|
68 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
69 |
+
),
|
70 |
+
GTM4WP_OPTION_INCLUDE_POSTCOUNT => array(
|
71 |
+
'label' => __( 'Post count', 'duracelltomi-google-tag-manager' ),
|
72 |
+
'description' => __( 'Check this option to include the count of the posts currently shown on the page and the total number of posts in the category/tag/any taxonomy.', 'duracelltomi-google-tag-manager' ),
|
73 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
74 |
+
),
|
75 |
+
GTM4WP_OPTION_INCLUDE_POSTID => array(
|
76 |
+
'label' => __( 'Post ID', 'duracelltomi-google-tag-manager' ),
|
77 |
+
'description' => __( 'Check this option to include the post id.', 'duracelltomi-google-tag-manager' ),
|
78 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
79 |
+
),
|
80 |
+
GTM4WP_OPTION_INCLUDE_POSTFORMAT => array(
|
81 |
+
'label' => __( 'Post Format', 'duracelltomi-google-tag-manager' ),
|
82 |
+
'description' => __( 'Check this option to include the post format.', 'duracelltomi-google-tag-manager' ),
|
83 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
84 |
+
),
|
85 |
+
GTM4WP_OPTION_INCLUDE_POSTTERMLIST => array(
|
86 |
+
"label" => __( "Post Terms", 'duracelltomi-google-tag-manager' ),
|
87 |
+
"description" => __( "Check this option to include taxonomy values associated with a given post.", 'duracelltomi-google-tag-manager' ),
|
88 |
+
"phase" => GTM4WP_PHASE_STABLE
|
89 |
+
),
|
90 |
+
GTM4WP_OPTION_INCLUDE_SEARCHDATA => array(
|
91 |
+
'label' => __( 'Search data', 'duracelltomi-google-tag-manager' ),
|
92 |
+
'description' => __( 'Check this option to include the search term, referring page URL and number of results on the search page.', 'duracelltomi-google-tag-manager' ),
|
93 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
94 |
+
),
|
95 |
+
GTM4WP_OPTION_INCLUDE_LOGGEDIN => array(
|
96 |
+
'label' => __( 'Logged in status', 'duracelltomi-google-tag-manager' ),
|
97 |
+
'description' => __( 'Check this option to include whether there is a logged in user on your website.', 'duracelltomi-google-tag-manager' ),
|
98 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
99 |
+
),
|
100 |
+
GTM4WP_OPTION_INCLUDE_USERROLE => array(
|
101 |
+
'label' => __( 'Logged in user role', 'duracelltomi-google-tag-manager' ),
|
102 |
+
'description' => __( 'Check this option to include the role of the logged in user.', 'duracelltomi-google-tag-manager' ),
|
103 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
104 |
+
),
|
105 |
+
GTM4WP_OPTION_INCLUDE_USERID => array(
|
106 |
+
'label' => __( 'Logged in user ID', 'duracelltomi-google-tag-manager' ),
|
107 |
+
'description' => __( 'Check this option to include the ID of the logged in user.', 'duracelltomi-google-tag-manager' ),
|
108 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
109 |
+
),
|
110 |
+
GTM4WP_OPTION_INCLUDE_USERNAME => array(
|
111 |
+
'label' => __( 'Logged in user name', 'duracelltomi-google-tag-manager' ),
|
112 |
+
'description' => __( 'Check this option to include the username of the logged in user.', 'duracelltomi-google-tag-manager' ),
|
113 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
114 |
+
),
|
115 |
+
GTM4WP_OPTION_INCLUDE_USEREMAIL => array(
|
116 |
+
'label' => __( 'Logged in user email', 'duracelltomi-google-tag-manager' ),
|
117 |
+
'description' => __( 'Check this option to include the email address of the logged in user.', 'duracelltomi-google-tag-manager' ),
|
118 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
119 |
+
),
|
120 |
+
GTM4WP_OPTION_INCLUDE_USERREGDATE => array(
|
121 |
+
'label' => __( 'Logged in user creation date', 'duracelltomi-google-tag-manager' ),
|
122 |
+
'description' => __( 'Check this option to include the date of creation (registration) of the logged in user.', 'duracelltomi-google-tag-manager' ),
|
123 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
124 |
+
),
|
125 |
+
GTM4WP_OPTION_INCLUDE_VISITOR_IP => array(
|
126 |
+
'label' => __( 'Visitor IP', 'duracelltomi-google-tag-manager' ),
|
127 |
+
'description' => __( 'Check this option to include the IP address of the visitor. You might use this to filter internal traffic inside your GTM container. Please be aware that per GDPR its not allowed to transmit this full IP address to Google Analytics or to any other measurement system without explicit consent from the visitor.', 'duracelltomi-google-tag-manager' ),
|
128 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
129 |
+
),
|
130 |
+
GTM4WP_OPTION_INCLUDE_REMARKETING => array(
|
131 |
+
'label' => __( 'Remarketing variable', 'duracelltomi-google-tag-manager' ),
|
132 |
+
'description' => __( 'Check this option to include a dataLayer variable where all dataLayer values are stored to be included in your AdWords remarketing tag as a custom variable field', 'duracelltomi-google-tag-manager' ),
|
133 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
134 |
+
),
|
135 |
+
GTM4WP_OPTION_INCLUDE_BROWSERDATA => array(
|
136 |
+
'label' => __( 'Browser data *', 'duracelltomi-google-tag-manager' ),
|
137 |
+
'description' => __( 'Check this option to include the name, version and engine data of the browser the visitor uses.', 'duracelltomi-google-tag-manager' ),
|
138 |
+
'phase' => GTM4WP_PHASE_BETA,
|
139 |
+
),
|
140 |
+
GTM4WP_OPTION_INCLUDE_OSDATA => array(
|
141 |
+
'label' => __( 'OS data *', 'duracelltomi-google-tag-manager' ),
|
142 |
+
'description' => __( 'Check this option to include the name and version of the operating system the visitor uses.', 'duracelltomi-google-tag-manager' ),
|
143 |
+
'phase' => GTM4WP_PHASE_BETA,
|
144 |
+
),
|
145 |
+
GTM4WP_OPTION_INCLUDE_DEVICEDATA => array(
|
146 |
+
'label' => __( 'Device data *', 'duracelltomi-google-tag-manager' ),
|
147 |
+
'description' => __( 'Check this option to include the type of device the user is currently using (desktop, tablet or mobile) including manufacturer and model data.', 'duracelltomi-google-tag-manager' ),
|
148 |
+
'phase' => GTM4WP_PHASE_BETA,
|
149 |
+
),
|
150 |
+
GTM4WP_OPTION_INCLUDE_MISCGEO => array(
|
151 |
+
'label' => __( 'Geo data', 'duracelltomi-google-tag-manager' ),
|
152 |
+
'description' => __( 'Add geo data (latitude, longitude, country, city, etc) of the current visitor (provided by ipstack.com)', 'duracelltomi-google-tag-manager' ),
|
153 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
154 |
+
),
|
155 |
+
GTM4WP_OPTION_INCLUDE_MISCGEOAPI => array(
|
156 |
+
'label' => __( 'IPStack.com API key', 'duracelltomi-google-tag-manager' ),
|
157 |
+
'description' => sprintf( __( 'Enter your IPStack.com API key here. <a href="%s" target="_blank">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ), 'https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress' ),
|
158 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
159 |
+
),
|
160 |
+
GTM4WP_OPTION_INCLUDE_MISCGEOCF => array(
|
161 |
+
'label' => __( 'Cloudflare country code', 'duracelltomi-google-tag-manager' ),
|
162 |
+
'description' => __( 'Add the country code of the user provided by Cloudflare (if Cloudflare is used with your site)', 'duracelltomi-google-tag-manager' ),
|
163 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
164 |
+
),
|
165 |
+
GTM4WP_OPTION_INCLUDE_WEATHER => array(
|
166 |
+
'label' => __( 'Weather data', 'duracelltomi-google-tag-manager' ),
|
167 |
+
'description' => sprintf(
|
168 |
+
__(
|
169 |
+
'Check this option to include the current weather conditions around the current visitor.<br /><br />' .
|
170 |
+
'<strong>Attention!</strong> This feature uses <a href="%s" target="_blank">ipstack.com</a> and ' .
|
171 |
+
'<a href="%s" target="_blank">openweathermap.org</a> to collect data.<br />' .
|
172 |
+
"Depending on your website's traffic, additional fees may apply!<br />" .
|
173 |
+
'This plugin caches weather data for 1 hour to lower the need to access those services.<br /><br />' .
|
174 |
+
'If you activate weather data, <strong>you will need</strong> to add an IPStack.com API key regardless of whether you ' .
|
175 |
+
"activate the 'Geo data' option!",
|
176 |
+
'duracelltomi-google-tag-manager'
|
177 |
+
),
|
178 |
+
'https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress',
|
179 |
+
'http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress'
|
180 |
),
|
181 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
182 |
),
|
183 |
+
GTM4WP_OPTION_INCLUDE_WEATHERUNITS => array(
|
184 |
+
'label' => __( 'Weather data units', 'duracelltomi-google-tag-manager' ),
|
185 |
+
'description' => __( 'Select which temperature units you would like to use.', 'duracelltomi-google-tag-manager' ),
|
186 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
187 |
),
|
188 |
GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => array(
|
189 |
+
'label' => __( 'OpenWeatherMap API key', 'duracelltomi-google-tag-manager' ),
|
190 |
+
'description' => sprintf( __( 'Enter your OpenWeatherMap API key here. <a href="%s" target="_blank">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ), 'http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress' ),
|
191 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
192 |
),
|
193 |
+
GTM4WP_OPTION_INCLUDE_SITEID => array(
|
194 |
+
'label' => __( 'Site ID', 'duracelltomi-google-tag-manager' ),
|
195 |
+
'description' => __( 'ID of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
|
196 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
197 |
+
),
|
198 |
+
GTM4WP_OPTION_INCLUDE_SITENAME => array(
|
199 |
+
'label' => __( 'Site name', 'duracelltomi-google-tag-manager' ),
|
200 |
+
'description' => __( 'Name of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
|
201 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
202 |
),
|
|
|
|
|
|
|
|
|
|
|
203 |
);
|
204 |
|
205 |
+
$GLOBALS['gtm4wp_eventfieldtexts'] = array(
|
206 |
+
GTM4WP_OPTION_EVENTS_FORMMOVE => array(
|
207 |
+
'label' => __( 'Form fill events (gtm4wp.formElementEnter & gtm4wp.formElementLeave)', 'duracelltomi-google-tag-manager' ),
|
208 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor moves between elements of a form (comment, contact, etc).', 'duracelltomi-google-tag-manager' ),
|
209 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
210 |
+
),
|
211 |
+
GTM4WP_OPTION_EVENTS_NEWUSERREG => array(
|
212 |
+
'label' => __( 'New user registration', 'duracelltomi-google-tag-manager' ),
|
213 |
+
'description' => __( 'Check this option to include a Tag Manager event when a new user registration has been completed on the frontend of your site (admin events not included)', 'duracelltomi-google-tag-manager' ),
|
214 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
215 |
+
),
|
216 |
+
GTM4WP_OPTION_EVENTS_USERLOGIN => array(
|
217 |
+
'label' => __( 'User logged in', 'duracelltomi-google-tag-manager' ),
|
218 |
+
'description' => __( 'Check this option to include a Tag Manager event when an existing user has been logged in on the frontend of your site (admin events not included)', 'duracelltomi-google-tag-manager' ),
|
219 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
220 |
+
),
|
221 |
+
GTM4WP_OPTION_EVENTS_YOUTUBE => array(
|
222 |
+
'label' => __( 'YouTube video events', 'duracelltomi-google-tag-manager' ),
|
223 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a YouTube video embeded on your site.', 'duracelltomi-google-tag-manager' ),
|
224 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
225 |
+
),
|
226 |
+
GTM4WP_OPTION_EVENTS_VIMEO => array(
|
227 |
+
'label' => __( 'Vimeo video events', 'duracelltomi-google-tag-manager' ),
|
228 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a Vimeo video embeded on your site.', 'duracelltomi-google-tag-manager' ),
|
229 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
230 |
+
),
|
231 |
+
GTM4WP_OPTION_EVENTS_SOUNDCLOUD => array(
|
232 |
+
'label' => __( 'Soundcloud events', 'duracelltomi-google-tag-manager' ),
|
233 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a Soundcloud media embeded on your site.', 'duracelltomi-google-tag-manager' ),
|
234 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
235 |
+
),
|
236 |
+
GTM4WP_OPTION_EVENTS_SOCIAL => array(
|
237 |
+
'label' => __( 'Social actions (gtm4wp.socialAction)', 'duracelltomi-google-tag-manager' ),
|
238 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor uses a social button to share/like content on a social network.', 'duracelltomi-google-tag-manager' ),
|
239 |
+
'phase' => GTM4WP_PHASE_DEPRECATED,
|
240 |
),
|
241 |
GTM4WP_OPTION_EVENTS_OUTBOUND => array(
|
242 |
+
'label' => __( 'Outbound link click events (gtm4wp.outboundClick)', 'duracelltomi-google-tag-manager' ),
|
243 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor clicks on a link directing the visitor out of your website.', 'duracelltomi-google-tag-manager' ),
|
244 |
+
'phase' => GTM4WP_PHASE_DEPRECATED,
|
245 |
),
|
246 |
GTM4WP_OPTION_EVENTS_DOWNLOADS => array(
|
247 |
+
'label' => __( 'Download click events (gtm4wp.downloadClick)', 'duracelltomi-google-tag-manager' ),
|
248 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitors clicks on a link that leads to a downloadable file on your website.', 'duracelltomi-google-tag-manager' ),
|
249 |
+
'phase' => GTM4WP_PHASE_DEPRECATED,
|
250 |
),
|
251 |
GTM4WP_OPTION_EVENTS_DWLEXT => array(
|
252 |
+
'label' => __( 'Extensions to track', 'duracelltomi-google-tag-manager' ),
|
253 |
+
'description' => __( "Enter a comma separated list of extensions to track when 'Include download click events' option is set.", 'duracelltomi-google-tag-manager' ),
|
254 |
+
'phase' => GTM4WP_PHASE_DEPRECATED,
|
255 |
),
|
256 |
GTM4WP_OPTION_EVENTS_EMAILCLICKS => array(
|
257 |
+
'label' => __( 'Email click events (gtm4wp.emailClick)', 'duracelltomi-google-tag-manager' ),
|
258 |
+
'description' => __( 'Check this option to include a Tag Manager event when a visitor clicks on an email link.', 'duracelltomi-google-tag-manager' ),
|
259 |
+
'phase' => GTM4WP_PHASE_DEPRECATED,
|
260 |
+
),
|
261 |
);
|
262 |
|
263 |
+
$GLOBALS['gtm4wp_scrollerfieldtexts'] = array(
|
264 |
GTM4WP_OPTION_SCROLLER_ENABLED => array(
|
265 |
+
'label' => __( 'Enabled', 'duracelltomi-google-tag-manager' ),
|
266 |
+
'description' => __( 'Enable scroll tracker script on your website.', 'duracelltomi-google-tag-manager' ),
|
267 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
268 |
),
|
269 |
GTM4WP_OPTION_SCROLLER_DEBUGMODE => array(
|
270 |
+
'label' => __( 'Debug mode', 'duracelltomi-google-tag-manager' ),
|
271 |
+
'description' => __( 'Fire console.log() commands instead of dataLayer events.', 'duracelltomi-google-tag-manager' ),
|
272 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
273 |
),
|
274 |
GTM4WP_OPTION_SCROLLER_CALLBACKTIME => array(
|
275 |
+
'label' => __( 'Time delay before location check', 'duracelltomi-google-tag-manager' ),
|
276 |
+
'description' => __( 'Enter the number of milliseconds after the script checks the current location. It prevents too many events being fired while scrolling.', 'duracelltomi-google-tag-manager' ),
|
277 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
278 |
),
|
279 |
GTM4WP_OPTION_SCROLLER_DISTANCE => array(
|
280 |
+
'label' => __( 'Minimum distance', 'duracelltomi-google-tag-manager' ),
|
281 |
+
'description' => __( 'The minimum amount of pixels that a visitor has to scroll before we treat the move as scrolling.', 'duracelltomi-google-tag-manager' ),
|
282 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
283 |
),
|
284 |
GTM4WP_OPTION_SCROLLER_CONTENTID => array(
|
285 |
+
'label' => __( 'Content ID', 'duracelltomi-google-tag-manager' ),
|
286 |
+
'description' => __( 'Enter the DOM ID of the content element in your template. Leave it empty for default(content). Do not include the # sign.', 'duracelltomi-google-tag-manager' ),
|
287 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
288 |
),
|
289 |
GTM4WP_OPTION_SCROLLER_READERTIME => array(
|
290 |
+
'label' => __( 'Scroller time', 'duracelltomi-google-tag-manager' ),
|
291 |
+
'description' => __( 'Enter the number of seconds after the the scroller user is being treated as a reader, someone who really reads the content, not just scrolls through it.', 'duracelltomi-google-tag-manager' ),
|
292 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
293 |
+
),
|
294 |
);
|
295 |
|
296 |
+
$GLOBALS['gtm4wp_blacklistfieldtexts'] = array(
|
297 |
+
GTM4WP_OPTION_BLACKLIST_ENABLE => array(
|
298 |
+
'label' => __( 'Enable blacklist/whitelist', 'duracelltomi-google-tag-manager' ),
|
299 |
+
'description' => __( 'Disable feature or select whether you want to whitelist or blacklist tags', 'duracelltomi-google-tag-manager' ),
|
300 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
301 |
+
),
|
302 |
+
GTM4WP_OPTION_BLACKLIST_AWCONV => array(
|
303 |
+
'label' => __( 'AdWords Conversion Tracking Tag', 'duracelltomi-google-tag-manager' ),
|
304 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
305 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
306 |
+
),
|
307 |
+
GTM4WP_OPTION_BLACKLIST_AWREMARKET => array(
|
308 |
+
'label' => __( 'AdWords Remarketing Tag', 'duracelltomi-google-tag-manager' ),
|
309 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
310 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
311 |
+
),
|
312 |
+
GTM4WP_OPTION_BLACKLIST_GACLASSIC => array(
|
313 |
+
'label' => __( 'Google Analytics Tag', 'duracelltomi-google-tag-manager' ),
|
314 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
315 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
316 |
+
),
|
317 |
+
GTM4WP_OPTION_BLACKLIST_UA => array(
|
318 |
+
'label' => __( 'Universal Analytics Tag', 'duracelltomi-google-tag-manager' ),
|
319 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
320 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
321 |
+
),
|
322 |
+
GTM4WP_OPTION_BLACKLIST_ADADVISOR => array(
|
323 |
+
'label' => __( 'AdAdvisor Tag', 'duracelltomi-google-tag-manager' ),
|
324 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
325 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
326 |
+
),
|
327 |
+
GTM4WP_OPTION_BLACKLIST_ADROLL => array(
|
328 |
+
'label' => __( 'AdRoll Smart Pixel Tag', 'duracelltomi-google-tag-manager' ),
|
329 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
330 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
331 |
+
),
|
332 |
+
GTM4WP_OPTION_BLACKLIST_BIZO => array(
|
333 |
+
'label' => __( 'Bizo Insight Tag', 'duracelltomi-google-tag-manager' ),
|
334 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
335 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
336 |
+
),
|
337 |
+
GTM4WP_OPTION_BLACKLIST_CLICKTALE => array(
|
338 |
+
'label' => __( 'ClickTale Standard Tracking Tag', 'duracelltomi-google-tag-manager' ),
|
339 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
340 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
341 |
+
),
|
342 |
+
GTM4WP_OPTION_BLACKLIST_COMSCORE => array(
|
343 |
+
'label' => __( 'comScore Unified Digital Measurement Tag', 'duracelltomi-google-tag-manager' ),
|
344 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
345 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
346 |
+
),
|
347 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMHTML => array(
|
348 |
+
'label' => __( 'Custom HTML Tag', 'duracelltomi-google-tag-manager' ),
|
349 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
350 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
351 |
+
),
|
352 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMIMG => array(
|
353 |
+
'label' => __( 'Custom Image Tag', 'duracelltomi-google-tag-manager' ),
|
354 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
355 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
356 |
+
),
|
357 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT => array(
|
358 |
+
'label' => __( 'DoubleClick Floodlight Counter Tag', 'duracelltomi-google-tag-manager' ),
|
359 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
360 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
361 |
+
),
|
362 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKSALES => array(
|
363 |
+
'label' => __( 'DoubleClick Floodlight Sales Tag', 'duracelltomi-google-tag-manager' ),
|
364 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
365 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
366 |
),
|
367 |
GTM4WP_OPTION_BLACKLIST_MARIN => array(
|
368 |
+
'label' => __( 'Marin Software Tag', 'duracelltomi-google-tag-manager' ),
|
369 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
370 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
371 |
+
),
|
372 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME => array(
|
373 |
+
'label' => __( 'Mediaplex - IFRAME MCT Tag', 'duracelltomi-google-tag-manager' ),
|
374 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
375 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
376 |
+
),
|
377 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXROI => array(
|
378 |
+
'label' => __( 'Mediaplex - Standard IMG ROI Tag', 'duracelltomi-google-tag-manager' ),
|
379 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
380 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
381 |
+
),
|
382 |
+
GTM4WP_OPTION_BLACKLIST_MEDIA6DEG => array(
|
383 |
+
'label' => __( 'Media6Degrees Universal Pixel Tag', 'duracelltomi-google-tag-manager' ),
|
384 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
385 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
386 |
+
),
|
387 |
+
GTM4WP_OPTION_BLACKLIST_TURNCONV => array(
|
388 |
+
'label' => __( 'Turn Conversion Tracking Tag', 'duracelltomi-google-tag-manager' ),
|
389 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
390 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
391 |
+
),
|
392 |
+
GTM4WP_OPTION_BLACKLIST_TURNDATA => array(
|
393 |
+
'label' => __( 'Turn Data Collection Tag', 'duracelltomi-google-tag-manager' ),
|
394 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
395 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
396 |
),
|
|
|
|
|
|
|
|
|
|
|
397 |
);
|
398 |
|
399 |
+
$GLOBALS['gtm4wp_blacklistmfieldtexts'] = array(
|
400 |
GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT => array(
|
401 |
+
'label' => __( 'DOM element Macro', 'duracelltomi-google-tag-manager' ),
|
402 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
403 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
404 |
),
|
405 |
GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS => array(
|
406 |
+
'label' => __( 'Custom JavaScript Macro', 'duracelltomi-google-tag-manager' ),
|
407 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
408 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
409 |
),
|
410 |
GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT => array(
|
411 |
+
'label' => __( 'Constant Macro', 'duracelltomi-google-tag-manager' ),
|
412 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
413 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
414 |
),
|
415 |
GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE => array(
|
416 |
+
'label' => __( 'First Party Cookie Macro', 'duracelltomi-google-tag-manager' ),
|
417 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
418 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
419 |
),
|
420 |
GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME => array(
|
421 |
+
'label' => __( 'Event Name Macro', 'duracelltomi-google-tag-manager' ),
|
422 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
423 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
424 |
),
|
425 |
GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR => array(
|
426 |
+
'label' => __( 'JavaScript Variable Macro', 'duracelltomi-google-tag-manager' ),
|
427 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
428 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
429 |
),
|
430 |
GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR => array(
|
431 |
+
'label' => __( 'DataLayer Variable Macro', 'duracelltomi-google-tag-manager' ),
|
432 |
+
'description' => __( 'It is not recommended to blacklist this type of macro since most features of this plugin depend on dataLayer macros.', 'duracelltomi-google-tag-manager' ),
|
433 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
434 |
),
|
435 |
GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM => array(
|
436 |
+
'label' => __( 'Random Number Macro', 'duracelltomi-google-tag-manager' ),
|
437 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
438 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
439 |
),
|
440 |
GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER => array(
|
441 |
+
'label' => __( 'Referrer Macro', 'duracelltomi-google-tag-manager' ),
|
442 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
443 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
444 |
),
|
445 |
GTM4WP_OPTION_BLACKLIST_MACRO_URL => array(
|
446 |
+
'label' => __( 'URL Macro', 'duracelltomi-google-tag-manager' ),
|
447 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
448 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
449 |
),
|
450 |
GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT => array(
|
451 |
+
'label' => __( 'Auto-Event Variable Macro', 'duracelltomi-google-tag-manager' ),
|
452 |
+
'description' => __( '', 'duracelltomi-google-tag-manager' ),
|
453 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
454 |
+
),
|
455 |
);
|
456 |
|
457 |
+
$GLOBALS['gtm4wp_integratefieldtexts'] = array(
|
458 |
+
GTM4WP_OPTION_INTEGRATE_WPCF7 => array(
|
459 |
+
'label' => __( 'Contact Form 7', 'duracelltomi-google-tag-manager' ),
|
460 |
+
'description' => __( 'Check this to include a dataLayer event after a successfull form submission.', 'duracelltomi-google-tag-manager' ),
|
461 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
462 |
+
'plugintocheck' => 'contact-form-7/wp-contact-form-7.php',
|
463 |
+
),
|
464 |
+
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => array(
|
465 |
+
'label' => __( 'Track classic e-commerce', 'duracelltomi-google-tag-manager' ),
|
466 |
+
'description' => sprintf( __( 'Choose this option if you would like to track e-commerce data using <a href="%s" target="_blank">classic transaction data</a>.', 'duracelltomi-google-tag-manager' ), 'https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce' ),
|
467 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
468 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
469 |
+
),
|
470 |
+
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => array(
|
471 |
+
'label' => __( 'Track enhanced e-commerce', 'duracelltomi-google-tag-manager' ),
|
472 |
+
'description' => sprintf( __( 'Choose this option if you would like to track e-commerce data using <a href="%s" target="_blank">enhanced ecommerce tracking</a>.', 'duracelltomi-google-tag-manager' ), 'https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce' ),
|
473 |
+
'phase' => GTM4WP_PHASE_BETA,
|
474 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
475 |
+
),
|
476 |
+
GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION => array(
|
477 |
+
'label' => __( 'Products per impression', 'duracelltomi-google-tag-manager' ),
|
478 |
+
'description' => __(
|
479 |
+
'If you have many products shown on product category pages and/or on your site home, you could miss pageviews in Google Analytics due to the ' .
|
480 |
+
'amount of data that is needed to be sent. To prevent this, you can split product impression data into multiple Google Analytics events by ' .
|
481 |
+
'entering a number here (minimum 10-15 recommended) and adding gtm4wp.productImpressionEEC into your Google Analytics ecommerce event helper ' .
|
482 |
+
"tag's trigger.<br /><br />Leave this value 0 to include product impression data in your pageview hit.",
|
483 |
+
'duracelltomi-google-tag-manager'
|
484 |
+
),
|
485 |
+
'phase' => GTM4WP_PHASE_BETA,
|
486 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
487 |
+
),
|
488 |
+
GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP => array(
|
489 |
+
'label' => __( 'Cart as 1st checkout step', 'duracelltomi-google-tag-manager' ),
|
490 |
+
'description' => __( 'Enable this to track the cart page as the first checkout step in enhanced ecommerce instead of the checkout page itself', 'duracelltomi-google-tag-manager' ),
|
491 |
+
'phase' => GTM4WP_PHASE_BETA,
|
492 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
493 |
+
),
|
494 |
+
GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL => array(
|
495 |
+
"label" => __( "Cart content in data layer", 'duracelltomi-google-tag-manager' ),
|
496 |
+
"description" => __( "Enable this option to include the content of the cart in the data layer on each page. Needs WooCommerce v3.2 or newer. Especially useful for site personalization with Google Optimize.", 'duracelltomi-google-tag-manager' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
"phase" => GTM4WP_PHASE_BETA,
|
498 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
499 |
),
|
500 |
GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH => array(
|
501 |
+
'label' => __( 'Include full category path.', 'duracelltomi-google-tag-manager' ),
|
502 |
+
'description' => __( 'Check this to inclulde the full category path of each product in enhanced ecommerce tracking. WARNING! This can lead to performance issues on large sites with lots of traffic!', 'duracelltomi-google-tag-manager' ),
|
503 |
+
'phase' => GTM4WP_PHASE_BETA,
|
504 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
505 |
+
),
|
506 |
+
GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY => array(
|
507 |
+
"label" => __( "Taxonomy to be used for product brands", 'duracelltomi-google-tag-manager' ),
|
508 |
+
"description" => __( "Select which custom taxonomy is being used to add the brand of products", 'duracelltomi-google-tag-manager' ),
|
509 |
"phase" => GTM4WP_PHASE_BETA,
|
510 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
511 |
),
|
512 |
+
GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => array(
|
513 |
+
'label' => __( 'Customer data in data layer', 'duracelltomi-google-tag-manager' ),
|
514 |
+
'description' => __( 'Enable this to add all customer data (billing and shipping data, total number of orders and order value) into the data layer (WooCommerce 3.x required)', 'duracelltomi-google-tag-manager' ),
|
515 |
+
'phase' => GTM4WP_PHASE_BETA,
|
516 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
517 |
+
),
|
518 |
+
GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => array(
|
519 |
+
'label' => __( 'Exclude tax from revenue', 'duracelltomi-google-tag-manager' ),
|
520 |
+
'description' => __( 'Enable this to exclude tax from the revenue variable while generating the purchase data', 'duracelltomi-google-tag-manager' ),
|
521 |
+
'phase' => GTM4WP_PHASE_BETA,
|
522 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
523 |
+
),
|
524 |
+
GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => array(
|
525 |
+
'label' => __( 'Exclude shipping from revenue', 'duracelltomi-google-tag-manager' ),
|
526 |
+
'description' => __( 'Enable this to exclude shipping costs from the revenue variable while generating the purchase data', 'duracelltomi-google-tag-manager' ),
|
527 |
+
'phase' => GTM4WP_PHASE_BETA,
|
528 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
529 |
+
),
|
530 |
+
GTM4WP_OPTION_INTEGRATE_WCREMARKETING => array(
|
531 |
+
'label' => __( 'AdWords Remarketing', 'duracelltomi-google-tag-manager' ),
|
532 |
+
'description' => __( 'Enable this to add Google AdWords dynamic remarketing variables to the dataLayer', 'duracelltomi-google-tag-manager' ),
|
533 |
+
'phase' => GTM4WP_PHASE_BETA,
|
534 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
535 |
+
),
|
536 |
+
GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => array(
|
537 |
+
'label' => __( 'Product ID prefix', 'duracelltomi-google-tag-manager' ),
|
538 |
+
'description' => __( "Some product feed generator plugins prefix product IDs with a fixed text like 'woocommerce_gpf'. You can enter this prefix here so that tags in your website include this prefix as well.", 'duracelltomi-google-tag-manager' ),
|
539 |
+
'phase' => GTM4WP_PHASE_BETA,
|
540 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
541 |
+
),
|
542 |
+
GTM4WP_OPTION_INTEGRATE_WCUSESKU => array(
|
543 |
+
'label' => __( 'Use SKU instead of ID', 'duracelltomi-google-tag-manager' ),
|
544 |
+
'description' => __( 'Check this to use product SKU instead of the ID of the products for remarketing and ecommerce tracking. Will fallback to ID if no SKU is set.', 'duracelltomi-google-tag-manager' ),
|
545 |
+
'phase' => GTM4WP_PHASE_BETA,
|
546 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
547 |
+
),
|
548 |
+
GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => array(
|
549 |
+
'label' => __( 'Do not flag orders as being tracked', 'duracelltomi-google-tag-manager' ),
|
550 |
+
'description' => __(
|
551 |
+
'Check this to prevent the plugin to flag orders as being already tracked.<br /><br />This ensures that no order data will be tracked ' .
|
552 |
+
'multiple times in any ad or measurement system so please only enable this feature if you really need it (with iDeal you might need this)!',
|
553 |
+
'duracelltomi-google-tag-manager'
|
554 |
+
),
|
555 |
+
'phase' => GTM4WP_PHASE_BETA,
|
556 |
+
'plugintocheck' => 'woocommerce/woocommerce.php',
|
557 |
+
),
|
558 |
+
|
559 |
+
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => array(
|
560 |
+
'label' => __( 'Google Optimize container ID list', 'duracelltomi-google-tag-manager' ),
|
561 |
+
'description' => sprintf(
|
562 |
+
__(
|
563 |
+
'Enter a comma separated list of Google Optimize container IDs that you would like to use on your site.<br />' .
|
564 |
+
'This plugin will add the <a href="%s">page-hiding snippet</a> to your pages.<br /><br />' .
|
565 |
+
'The Google Optimize container will be only loaded if you provide your Google Analytics property ID bellow as well.',
|
566 |
+
'duracelltomi-google-tag-manager'
|
567 |
+
),
|
568 |
+
'https://developers.google.com/optimize/#the_page-hiding_snippet_code'
|
569 |
+
) .
|
570 |
+
'<br /><span class="goid_validation_error">' . __( 'This does not seems to be a valid Google Optimize ID! Valid format: GTM-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
|
571 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
572 |
),
|
573 |
+
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => array(
|
574 |
+
'label' => __( 'Google Optimize page-hiding timeout', 'duracelltomi-google-tag-manager' ),
|
575 |
+
'description' => __( 'Enter here the amount of time in milliseconds that the page-hiding snippet should wait before page content gets visible even if Google Optimize has not been completely loaded yet.', 'duracelltomi-google-tag-manager' ),
|
576 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
577 |
+
),
|
578 |
+
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID => array(
|
579 |
+
'label' => __( 'Google Optimize - Google Analytics property ID', 'duracelltomi-google-tag-manager' ),
|
580 |
+
'description' => __( 'If you enter your Google Analytics property ID here as well (UA-NNNNNN-N), this plugin will also load your Google Optimize container itself. Leave this blank to only load the page hiding snippet.', 'duracelltomi-google-tag-manager' ) .
|
581 |
+
'<br /><span class="goid_ga_validation_error">' . __( 'This does not seems to be a valid Google Analytics property ID! Valid format: UA-NNNNNN-N where N can be numbers. Enter a single property ID here.', 'duracelltomi-google-tag-manager' ) . '</span>',
|
582 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
583 |
),
|
584 |
|
585 |
+
GTM4WP_OPTION_INTEGRATE_AMPID => array(
|
586 |
+
'label' => __( "Google Tag Manager 'AMP' Container ID", 'duracelltomi-google-tag-manager' ),
|
587 |
+
'description' => sprintf( __( 'Enter a comma separated list of Google Tag Manager container IDs that you would like to use on your site. This plugin will add the <a href="%s">AMP GTM snippet</a> to your AMP pages.', 'duracelltomi-google-tag-manager' ), 'https://support.google.com/tagmanager/answer/6103696?hl=en' ) .
|
588 |
+
'<br /><span class="ampid_validation_error">' . __( 'This does not seems to be a valid Google Tag Manager Container ID! Valid format: GTM-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
|
589 |
+
'phase' => GTM4WP_PHASE_EXPERIMENTAL,
|
590 |
+
'plugintocheck' => 'amp/amp.php',
|
|
|
591 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
592 |
);
|
593 |
|
594 |
+
$GLOBALS['gtm4wp_advancedfieldtexts'] = array(
|
595 |
GTM4WP_OPTION_DATALAYER_NAME => array(
|
596 |
+
'label' => __( 'dataLayer variable name', 'duracelltomi-google-tag-manager' ),
|
597 |
+
'description' => __( 'In some cases you need to rename the dataLayer variable. You can enter your name here. Leave black for default name: dataLayer', 'duracelltomi-google-tag-manager' ),
|
598 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
599 |
),
|
600 |
GTM4WP_OPTION_ENV_GTM_AUTH => array(
|
601 |
+
'label' => __( 'Environment gtm_auth parameter', 'duracelltomi-google-tag-manager' ),
|
602 |
+
'description' => __( 'Enter the gtm_auth parameter of the Google Tag Manager environment that has to be activated on this site. Both gtm_auth and gtm_preview parameters are required to activate the desired environment.', 'duracelltomi-google-tag-manager' ),
|
603 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
604 |
),
|
605 |
GTM4WP_OPTION_ENV_GTM_PREVIEW => array(
|
606 |
+
'label' => __( 'Environment gtm_preview parameter', 'duracelltomi-google-tag-manager' ),
|
607 |
+
'description' => __( 'Enter the gtm_auth parameter of the Google Tag Manager environment that has to be activated on this site. Both gtm_auth and gtm_preview parameters are required to activate the desired environment.', 'duracelltomi-google-tag-manager' ),
|
608 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
609 |
),
|
610 |
+
GTM4WP_OPTION_DONOTTRACK => array(
|
611 |
+
'label' => __( "Include browser 'Do not track' setting", 'duracelltomi-google-tag-manager' ),
|
612 |
+
'description' => __( 'Add into the data layer whether the user has asked not to track any website interaction. You may want to respect this and disable all tags if this variable is set in the data layer.', 'duracelltomi-google-tag-manager' ),
|
613 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
614 |
+
),
|
615 |
+
GTM4WP_OPTION_LOADEARLY => array(
|
616 |
+
'label' => __( 'Load GTM container as early as possible', 'duracelltomi-google-tag-manager' ),
|
617 |
+
'description' => __( "Turning on this option will load your Google Tag Manager container as early as possible during page load. This can cause issues if you are using jQuery in your custom HTML tags that fire on 'Page View' events.", 'duracelltomi-google-tag-manager' ),
|
618 |
+
'phase' => GTM4WP_PHASE_STABLE,
|
619 |
),
|
|
|
|
|
|
|
|
|
|
|
620 |
);
|
621 |
|
622 |
function gtm4wp_admin_output_section( $args ) {
|
623 |
echo '<span class="tabinfo">';
|
624 |
|
625 |
+
switch ( $args['id'] ) {
|
626 |
case GTM4WP_ADMIN_GROUP_GENERAL: {
|
627 |
_e( 'This plugin is intended to be used by IT girls&guys and marketing staff. Please be sure you read the <a href="https://developers.google.com/tag-manager/" target="_blank">Google Tag Manager Help Center</a> before you start using this plugin.<br /><br />', 'duracelltomi-google-tag-manager' );
|
628 |
|
630 |
}
|
631 |
|
632 |
case GTM4WP_ADMIN_GROUP_INCLUDES: {
|
633 |
+
_e( 'Here you can check what data is needed to be included in the dataLayer to be able to access them in Google Tag Manager', 'duracelltomi-google-tag-manager' );
|
634 |
+
echo '<br />';
|
635 |
+
printf( __( '* Browser, OS and Device data is provided using <a href="%s">WhichBrowser</a> library.', 'duracelltomi-google-tag-manager' ), 'http://whichbrowser.net/' );
|
636 |
if ( version_compare( PHP_VERSION, '5.4.0' ) < 0 ) {
|
637 |
+
echo '<br />';
|
638 |
_e( 'You are using an <strong>outdated</strong> version of PHP (v' . PHP_VERSION . '). You <strong>should not turn on</strong> browser/device/os tracking as this can hurt your site. Please talk to your hosting and upgrade to PHP 5.4 or newer.', 'duracelltomi-google-tag-manager' );
|
639 |
}
|
640 |
|
642 |
}
|
643 |
|
644 |
case GTM4WP_ADMIN_GROUP_EVENTS: {
|
645 |
+
_e( 'Fire tags in Google Tag Manager on special events on your website', 'duracelltomi-google-tag-manager' );
|
646 |
echo '<p style="font-weight: bold;">';
|
647 |
_e( 'In October 2013 Google released a new feature called <a href="https://support.google.com/tagmanager/answer/3415369?hl=en" target="_blank">auto event tracking</a>. It is up to you how you use click events either using Google\'s solution or the settings below.', 'duracelltomi-google-tag-manager' );
|
648 |
echo '</p>';
|
651 |
}
|
652 |
|
653 |
case GTM4WP_ADMIN_GROUP_SCROLLER: {
|
654 |
+
_e( 'Fire tags based on how the visitor scrolls through your page.', 'duracelltomi-google-tag-manager' );
|
655 |
echo '<br />';
|
656 |
+
printf( __( 'Based on the script originaly posted to <a href="%s">Analytics Talk</a>', 'duracelltomi-google-tag-manager' ), 'http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/' );
|
657 |
|
658 |
break;
|
659 |
}
|
660 |
|
661 |
case GTM4WP_ADMIN_GROUP_BLACKLIST: {
|
662 |
+
_e( 'Here you can control which types of tags and macros can be executed on your site regardless of what tags are included in your container on the Google Tag Manager site. Use this to increase security!', 'duracelltomi-google-tag-manager' );
|
663 |
echo '<br />';
|
664 |
+
_e( 'Do not modify if you do not know what to do since it can cause issues in your tag deployment!', 'duracelltomi-google-tag-manager' );
|
665 |
echo '<br />';
|
666 |
+
_e( 'Blacklisting of macros only work if you enable blacklist or whilelist of tags on the previous tab.', 'duracelltomi-google-tag-manager' );
|
667 |
echo '<br />';
|
668 |
+
_e( 'Uncheck a row to blacklist a macro type.', 'duracelltomi-google-tag-manager' );
|
669 |
|
670 |
break;
|
671 |
}
|
672 |
|
673 |
case GTM4WP_ADMIN_GROUP_INTEGRATION: {
|
674 |
+
_e( 'Google Tag Manager for WordPress can integrate with several popular plugins. Please check the plugins you would like to integrate with:', 'duracelltomi-google-tag-manager' );
|
675 |
|
676 |
break;
|
677 |
}
|
678 |
|
679 |
case GTM4WP_ADMIN_GROUP_ADVANCED: {
|
680 |
+
_e( 'You usually do not need to modify thoose settings. Please be carefull while hacking here.', 'duracelltomi-google-tag-manager' );
|
681 |
|
682 |
break;
|
683 |
}
|
684 |
|
685 |
case GTM4WP_ADMIN_GROUP_CREDITS: {
|
686 |
+
_e( 'Some info about the author of this plugin', 'duracelltomi-google-tag-manager' );
|
687 |
|
688 |
break;
|
689 |
}
|
695 |
function gtm4wp_admin_output_field( $args ) {
|
696 |
global $gtm4wp_options;
|
697 |
|
698 |
+
switch ( $args['label_for'] ) {
|
699 |
case GTM4WP_ADMIN_GROUP_GTMID: {
|
700 |
+
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" value="' . $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] . '" /><br />' . $args['description'];
|
701 |
+
echo '<br /><span class="gtmid_validation_error">' . __( 'This does not seems to be a valid Google Tag Manager ID! Valid format: GTM-XXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile container IDs.', 'duracelltomi-google-tag-manager' ) . '</span>';
|
702 |
|
703 |
break;
|
704 |
}
|
705 |
|
706 |
case GTM4WP_ADMIN_GROUP_PLACEMENT: {
|
707 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_FOOTER . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_FOOTER . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_FOOTER ? 'checked="checked"' : '' ) . '/> ' . __( 'Footer of the page (not recommended by Google, no tweak in your template required)', 'duracelltomi-google-tag-manager' ) . '<br />';
|
708 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_BODYOPEN . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_BODYOPEN . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN ? 'checked="checked"' : '' ) . '/> ' . __( 'Custom (needs tweak in your template)', 'duracelltomi-google-tag-manager' ) . '<br />';
|
709 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN_AUTO ? 'checked="checked"' : '' ) . '/> ' . __( 'Codeless injection (no tweak, right placement but experimental, could break your frontend)', 'duracelltomi-google-tag-manager' ) . '<br />';
|
710 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_' . GTM4WP_PLACEMENT_OFF . '" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="' . GTM4WP_PLACEMENT_OFF . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'Off (only add data layer to the page source)', 'duracelltomi-google-tag-manager' ) . '<br /><br />' . $args['description'];
|
711 |
|
712 |
break;
|
713 |
}
|
714 |
|
715 |
+
case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']': {
|
716 |
+
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" value="' . $gtm4wp_options[ GTM4WP_OPTION_DATALAYER_NAME ] . '" /><br />' . $args['description'];
|
717 |
+
echo '<br /><span class="datalayername_validation_error">' . __( 'This does not seems to be a valid JavaScript variable name! Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
|
718 |
|
719 |
break;
|
720 |
}
|
721 |
|
722 |
+
case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']': {
|
723 |
+
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" value="' . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] . '" /><br />' . $args['description'];
|
724 |
+
echo '<br /><span class="gtmauth_validation_error">' . __( 'This does not seems to be a valid gtm_auth parameter! It should only contain letters, number and the "-" character. Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
|
725 |
|
726 |
break;
|
727 |
}
|
728 |
|
729 |
+
case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']': {
|
730 |
+
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" value="' . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] . '" /><br />' . $args['description'];
|
731 |
+
echo '<br /><span class="gtmpreview_validation_error">' . __( 'This does not seems to be a valid gtm_preview parameter! It should have the format "env-NN" where NN is an integer number. Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
|
732 |
|
733 |
break;
|
734 |
}
|
735 |
|
736 |
+
case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']': {
|
737 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( 'Disable feature: control everything on Google Tag Manager interface', 'duracelltomi-google-tag-manager' ) . '<br />';
|
738 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( 'Allow all, except the checked items below (blacklist)', 'duracelltomi-google-tag-manager' ) . '<br />';
|
739 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_2" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="2" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 2 ? 'checked="checked"' : '' ) . '/> ' . __( 'Block all, except the checked items below (whitelist)', 'duracelltomi-google-tag-manager' ) . '<br />';
|
740 |
+
echo $args['description'];
|
741 |
|
742 |
break;
|
743 |
}
|
744 |
|
745 |
+
case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']': {
|
746 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( 'Celsius', 'duracelltomi-google-tag-manager' ) . '<br />';
|
747 |
+
echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( 'Fahrenheit', 'duracelltomi-google-tag-manager' ) . '<br />';
|
748 |
+
echo $args['description'];
|
749 |
|
750 |
break;
|
751 |
}
|
752 |
|
753 |
case GTM4WP_ADMIN_GROUP_INFO: {
|
754 |
+
echo $args['description'];
|
755 |
+
|
756 |
+
break;
|
757 |
+
}
|
758 |
+
|
759 |
+
case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . "]": {
|
760 |
+
echo '<select id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . ']">';
|
761 |
+
echo '<option value="">(not set)</option>';
|
762 |
+
|
763 |
+
$gtm4wp_taxonomies = get_taxonomies(array(
|
764 |
+
"show_ui" => true,
|
765 |
+
"public" => true,
|
766 |
+
"_builtin" => false
|
767 |
+
), "object", "and");
|
768 |
+
|
769 |
+
foreach( $gtm4wp_taxonomies as $onetaxonomy ) {
|
770 |
+
echo '<option value="' . $onetaxonomy->name . '"' . ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY] === $onetaxonomy->name ? ' selected="selected"' : '' ) . '>' . $onetaxonomy->label . '</option>';
|
771 |
+
}
|
772 |
+
|
773 |
+
echo '</select>';
|
774 |
|
775 |
break;
|
776 |
}
|
777 |
|
778 |
default: {
|
779 |
+
$optval = $gtm4wp_options[ $args['optionfieldid'] ];
|
780 |
|
781 |
// fix wrong data type saved in v0.4
|
782 |
+
if ( GTM4WP_OPTION_EVENTS_SOCIAL == $args['optionfieldid'] ) {
|
783 |
+
$optval = (bool) ( $optval );
|
784 |
}
|
785 |
|
786 |
+
switch ( gettype( $optval ) ) {
|
787 |
+
case 'boolean': {
|
788 |
+
echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="1" ' . checked( 1, $optval, false ) . ' /><br />' . $args['description'];
|
789 |
|
790 |
+
if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
|
791 |
+
if ( is_plugin_active( $args['plugintocheck'] ) ) {
|
792 |
+
echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
|
793 |
} else {
|
794 |
+
echo '<br />' . __( 'This plugin (' . $args['plugintocheck'] . ') is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
|
795 |
}
|
796 |
}
|
797 |
|
798 |
break;
|
799 |
}
|
800 |
|
801 |
+
case 'integer': {
|
802 |
+
echo '<input type="number" step="1" min="0" class="small-text" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="' . esc_attr( $optval ) . '" /><br />' . $args['description'];
|
803 |
|
804 |
+
if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
|
805 |
+
if ( is_plugin_active( $args['plugintocheck'] ) ) {
|
806 |
+
echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
|
807 |
} else {
|
808 |
+
echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
|
809 |
}
|
810 |
}
|
811 |
|
813 |
}
|
814 |
|
815 |
default : {
|
816 |
+
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="' . esc_attr( $optval ) . '" size="80" /><br />' . $args['description'];
|
817 |
|
818 |
+
if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
|
819 |
+
if ( is_plugin_active( $args['plugintocheck'] ) ) {
|
820 |
+
echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
|
821 |
} else {
|
822 |
+
echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
|
823 |
}
|
824 |
}
|
825 |
}
|
828 |
} // end switch
|
829 |
}
|
830 |
|
831 |
+
function gtm4wp_sanitize_options( $options ) {
|
832 |
global $wpdb;
|
833 |
|
834 |
$output = gtm4wp_reload_options();
|
835 |
|
836 |
+
foreach ( $output as $optionname => $optionvalue ) {
|
837 |
+
if ( isset( $options[ $optionname ] ) ) {
|
838 |
+
$newoptionvalue = $options[ $optionname ];
|
839 |
} else {
|
840 |
+
$newoptionvalue = '';
|
841 |
}
|
842 |
|
843 |
// "include" settings
|
844 |
+
if ( substr( $optionname, 0, 8 ) == 'include-' ) {
|
845 |
+
$output[ $optionname ] = (bool) $newoptionvalue;
|
846 |
|
847 |
+
// tracked download extensions
|
848 |
+
} elseif ( $optionname == GTM4WP_OPTION_EVENTS_DWLEXT ) {
|
849 |
+
$output[ $optionname ] = str_replace( ' ', '', trim( $newoptionvalue ) );
|
850 |
|
851 |
+
// dataLayer events
|
852 |
+
} elseif ( substr( $optionname, 0, 6 ) == 'event-' ) {
|
853 |
+
$output[ $optionname ] = (bool) $newoptionvalue;
|
854 |
|
855 |
// clear oembed transients when feature is enabled because we need to hook into the oembed process to enable some 3rd party APIs
|
856 |
+
if ( $output[ $optionname ] && ! $optionvalue ) {
|
857 |
if ( GTM4WP_OPTION_EVENTS_YOUTUBE == $optionname ) {
|
858 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%youtube.com%' AND meta_key LIKE '_oembed_%'" );
|
859 |
}
|
863 |
}
|
864 |
}
|
865 |
|
866 |
+
// Google Optimize settings
|
867 |
+
} elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ) {
|
868 |
+
$_goid_val = trim( $newoptionvalue );
|
869 |
+
if ( '' == $_goid_val ) {
|
870 |
$_goid_list = array();
|
871 |
} else {
|
872 |
+
$_goid_list = explode( ',', $_goid_val );
|
873 |
}
|
874 |
$_goid_haserror = false;
|
875 |
|
876 |
+
foreach ( $_goid_list as $one_go_id ) {
|
877 |
+
$_goid_haserror = $_goid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_go_id );
|
878 |
}
|
879 |
|
880 |
+
if ( $_goid_haserror && ( count( $_goid_list ) > 0 ) ) {
|
881 |
+
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Optimize ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
|
882 |
} else {
|
883 |
+
$output[ $optionname ] = $newoptionvalue;
|
884 |
}
|
885 |
+
} elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ) {
|
886 |
+
$_gaid_val = trim( $newoptionvalue );
|
887 |
+
if ( '' == $_gaid_val ) {
|
|
|
888 |
$_gaid_list = array();
|
889 |
} else {
|
890 |
+
$_gaid_list = explode( ',', $_gaid_val );
|
891 |
}
|
892 |
$_gaid_haserror = false;
|
893 |
|
894 |
+
foreach ( $_gaid_list as $one_ga_id ) {
|
895 |
+
$_gaid_haserror = $_gaid_haserror || ! preg_match( '/^UA-[0-9]+-[0-9]+$/', $one_ga_id );
|
896 |
}
|
897 |
|
898 |
+
if ( $_gaid_haserror && ( count( $_gaid_list ) > 0 ) ) {
|
899 |
+
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Analytics property ID. Valid ID format: UA-NNNNNN-N.', 'duracelltomi-google-tag-manager' ) );
|
900 |
} else {
|
901 |
+
$output[ $optionname ] = $newoptionvalue;
|
902 |
}
|
903 |
+
} elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ) {
|
904 |
+
$output[ $optionname ] = (int) $newoptionvalue;
|
905 |
|
906 |
+
} elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ) {
|
907 |
+
$output[ $optionname ] = (int) $newoptionvalue;
|
908 |
|
909 |
+
} elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ) {
|
910 |
+
$output[ $optionname ] = trim( (string) $newoptionvalue );
|
911 |
|
912 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ) {
|
913 |
$output[$optionname] = trim( (string) $newoptionvalue );
|
914 |
|
915 |
+
// Accelerated Mobile Pages settings
|
916 |
+
} elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_AMPID ) {
|
917 |
+
$_ampid_val = trim( $newoptionvalue );
|
918 |
+
if ( '' == $_ampid_val ) {
|
919 |
$_ampid_list = array();
|
920 |
} else {
|
921 |
+
$_ampid_list = explode( ',', $_ampid_val );
|
922 |
}
|
923 |
$_ampid_haserror = false;
|
924 |
|
925 |
+
foreach ( $_ampid_list as $one_amp_id ) {
|
926 |
+
$_ampid_haserror = $_ampid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_amp_id );
|
927 |
}
|
928 |
|
929 |
+
if ( $_ampid_haserror && ( count( $_ampid_list ) > 0 ) ) {
|
930 |
+
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_AMPID . ']', __( 'Invalid AMP Google Tag Manager Container ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
|
931 |
} else {
|
932 |
+
$output[ $optionname ] = $newoptionvalue;
|
933 |
}
|
934 |
|
935 |
+
// integrations
|
936 |
+
} elseif ( substr( $optionname, 0, 10 ) == 'integrate-' ) {
|
937 |
+
$output[ $optionname ] = (bool) $newoptionvalue;
|
938 |
|
939 |
+
// GTM code or dataLayer variable name
|
940 |
+
} elseif ( ( $optionname == GTM4WP_OPTION_GTM_CODE ) || ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) ) {
|
941 |
+
$newoptionvalue = trim( $newoptionvalue );
|
|
|
|
|
|
|
|
|
942 |
|
943 |
if ( $optionname == GTM4WP_OPTION_GTM_CODE ) {
|
944 |
+
$_gtmid_list = explode( ',', $newoptionvalue );
|
945 |
$_gtmid_haserror = false;
|
946 |
|
947 |
+
foreach ( $_gtmid_list as $one_gtm_id ) {
|
948 |
+
$_gtmid_haserror = $_gtmid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_gtm_id );
|
949 |
}
|
950 |
|
951 |
if ( $_gtmid_haserror ) {
|
952 |
+
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']', __( 'Invalid Google Tag Manager ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one container ID.', 'duracelltomi-google-tag-manager' ) );
|
953 |
} else {
|
954 |
+
$output[ $optionname ] = $newoptionvalue;
|
955 |
}
|
956 |
+
} elseif ( ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^[a-zA-Z][a-zA-Z0-9_-]*$/', $newoptionvalue ) ) ) {
|
957 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']', __( "Invalid dataLayer variable name. Please start with a character from a-z or A-Z followed by characters from a-z, A-Z, 0-9 or '_' or '-'!", 'duracelltomi-google-tag-manager' ) );
|
958 |
|
959 |
+
} elseif ( ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^[a-zA-Z0-9-_]+$/', $newoptionvalue ) ) ) {
|
960 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']', __( "Invalid gtm_auth environment parameter value. It should only contain letters, numbers or the '-' and '_' characters.", 'duracelltomi-google-tag-manager' ) );
|
961 |
|
962 |
+
} elseif ( ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^env-[0-9]+$/', $newoptionvalue ) ) ) {
|
963 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']', __( "Invalid gtm_preview environment parameter value. It should have the format 'env-NN' where NN is an integer number.", 'duracelltomi-google-tag-manager' ) );
|
964 |
|
965 |
} else {
|
966 |
+
$output[ $optionname ] = $newoptionvalue;
|
967 |
}
|
968 |
|
969 |
+
// GTM container code placement
|
970 |
+
} elseif ( $optionname == GTM4WP_OPTION_GTM_PLACEMENT ) {
|
971 |
+
$output[ $optionname ] = (int) $newoptionvalue;
|
972 |
+
if ( ( $output[ $optionname ] < 0 ) || ( $output[ $optionname ] > 3 ) ) {
|
973 |
+
$output[ $optionname ] = 0;
|
974 |
}
|
975 |
|
976 |
+
// scroll tracking content ID
|
977 |
+
} elseif ( $optionname == GTM4WP_OPTION_SCROLLER_CONTENTID ) {
|
978 |
+
$output[ $optionname ] = trim( str_replace( '#', '', $newoptionvalue ) );
|
979 |
|
980 |
+
// anything else
|
981 |
} else {
|
982 |
+
switch ( gettype( $optionvalue ) ) {
|
983 |
+
case 'boolean': {
|
984 |
+
$output[ $optionname ] = (bool) $newoptionvalue;
|
985 |
|
986 |
break;
|
987 |
}
|
988 |
|
989 |
+
case 'integer': {
|
990 |
+
$output[ $optionname ] = (int) $newoptionvalue;
|
991 |
|
992 |
break;
|
993 |
}
|
994 |
|
995 |
default: {
|
996 |
+
$output[ $optionname ] = $newoptionvalue;
|
997 |
}
|
998 |
} // end switch
|
999 |
}
|
1006 |
global $gtm4wp_includefieldtexts, $gtm4wp_eventfieldtexts, $gtm4wp_integratefieldtexts, $gtm4wp_scrollerfieldtexts,
|
1007 |
$gtm4wp_blacklistfieldtexts, $gtm4wp_blacklistmfieldtexts, $gtm4wp_advancedfieldtexts;
|
1008 |
|
1009 |
+
register_setting( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS, 'gtm4wp_sanitize_options' );
|
1010 |
|
1011 |
add_settings_section(
|
1012 |
GTM4WP_ADMIN_GROUP_GENERAL,
|
1022 |
GTM4WP_ADMINSLUG,
|
1023 |
GTM4WP_ADMIN_GROUP_GENERAL,
|
1024 |
array(
|
1025 |
+
'label_for' => GTM4WP_ADMIN_GROUP_GTMID,
|
1026 |
+
'description' => __( 'Enter your Google Tag Manager ID here. Use comma without space (,) to enter multiple IDs.', 'duracelltomi-google-tag-manager' ),
|
1027 |
)
|
1028 |
);
|
1029 |
|
1034 |
GTM4WP_ADMINSLUG,
|
1035 |
GTM4WP_ADMIN_GROUP_GENERAL,
|
1036 |
array(
|
1037 |
+
'label_for' => GTM4WP_ADMIN_GROUP_PLACEMENT,
|
1038 |
+
// "description" => __( "Select how your container code should be included in your website.<br />If you select 'Custom' you need to edit your template file and add the following line just after the opening <body> tag:<br /><code><?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?></code>", 'duracelltomi-google-tag-manager' )
|
1039 |
+
'description' => __( "Code placement decides where to put the second, so called noscript part of the GTM container code.<br />This code is usually only executed if your visitor has for some reason disabled JavaScript.<br/>The main GTM container code will be placed into the <code><head></code> section of your webpages anyway (where it belongs to).<br />If you select 'Custom' you need to edit your template file and add the following line just after the opening <code><body></code> tag:<br /><code><?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?></code>", 'duracelltomi-google-tag-manager' ),
|
1040 |
)
|
1041 |
);
|
1042 |
|
1047 |
GTM4WP_ADMINSLUG
|
1048 |
);
|
1049 |
|
1050 |
+
foreach ( $gtm4wp_includefieldtexts as $fieldid => $fielddata ) {
|
1051 |
add_settings_field(
|
1052 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1053 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1054 |
'gtm4wp_admin_output_field',
|
1055 |
GTM4WP_ADMINSLUG,
|
1056 |
GTM4WP_ADMIN_GROUP_INCLUDES,
|
1057 |
array(
|
1058 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1059 |
+
'description' => $fielddata['description'],
|
1060 |
+
'optionfieldid' => $fieldid,
|
1061 |
)
|
1062 |
);
|
1063 |
}
|
1069 |
GTM4WP_ADMINSLUG
|
1070 |
);
|
1071 |
|
1072 |
+
foreach ( $gtm4wp_eventfieldtexts as $fieldid => $fielddata ) {
|
1073 |
add_settings_field(
|
1074 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1075 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1076 |
'gtm4wp_admin_output_field',
|
1077 |
GTM4WP_ADMINSLUG,
|
1078 |
GTM4WP_ADMIN_GROUP_EVENTS,
|
1079 |
array(
|
1080 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1081 |
+
'description' => $fielddata['description'],
|
1082 |
+
'optionfieldid' => $fieldid,
|
1083 |
)
|
1084 |
);
|
1085 |
}
|
1091 |
GTM4WP_ADMINSLUG
|
1092 |
);
|
1093 |
|
1094 |
+
foreach ( $gtm4wp_scrollerfieldtexts as $fieldid => $fielddata ) {
|
1095 |
add_settings_field(
|
1096 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1097 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1098 |
'gtm4wp_admin_output_field',
|
1099 |
GTM4WP_ADMINSLUG,
|
1100 |
GTM4WP_ADMIN_GROUP_SCROLLER,
|
1101 |
array(
|
1102 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1103 |
+
'description' => $fielddata['description'],
|
1104 |
+
'optionfieldid' => $fieldid,
|
1105 |
)
|
1106 |
);
|
1107 |
}
|
1113 |
GTM4WP_ADMINSLUG
|
1114 |
);
|
1115 |
|
1116 |
+
foreach ( $gtm4wp_blacklistfieldtexts as $fieldid => $fielddata ) {
|
1117 |
add_settings_field(
|
1118 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1119 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1120 |
'gtm4wp_admin_output_field',
|
1121 |
GTM4WP_ADMINSLUG,
|
1122 |
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1123 |
array(
|
1124 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1125 |
+
'description' => $fielddata['description'],
|
1126 |
+
'optionfieldid' => $fieldid,
|
1127 |
)
|
1128 |
);
|
1129 |
}
|
1130 |
|
1131 |
+
foreach ( $gtm4wp_blacklistmfieldtexts as $fieldid => $fielddata ) {
|
1132 |
add_settings_field(
|
1133 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1134 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1135 |
'gtm4wp_admin_output_field',
|
1136 |
GTM4WP_ADMINSLUG,
|
1137 |
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1138 |
array(
|
1139 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1140 |
+
'description' => $fielddata['description'],
|
1141 |
+
'optionfieldid' => $fieldid,
|
1142 |
)
|
1143 |
);
|
1144 |
}
|
1150 |
GTM4WP_ADMINSLUG
|
1151 |
);
|
1152 |
|
1153 |
+
foreach ( $gtm4wp_integratefieldtexts as $fieldid => $fielddata ) {
|
1154 |
add_settings_field(
|
1155 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1156 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1157 |
'gtm4wp_admin_output_field',
|
1158 |
GTM4WP_ADMINSLUG,
|
1159 |
GTM4WP_ADMIN_GROUP_INTEGRATION,
|
1160 |
array(
|
1161 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1162 |
+
'description' => $fielddata['description'],
|
1163 |
+
'optionfieldid' => $fieldid,
|
1164 |
+
'plugintocheck' => isset( $fielddata['plugintocheck'] ) ? $fielddata['plugintocheck'] : '',
|
1165 |
)
|
1166 |
);
|
1167 |
}
|
1173 |
GTM4WP_ADMINSLUG
|
1174 |
);
|
1175 |
|
1176 |
+
foreach ( $gtm4wp_advancedfieldtexts as $fieldid => $fielddata ) {
|
1177 |
add_settings_field(
|
1178 |
+
'gtm4wp-admin-' . $fieldid . '-id',
|
1179 |
+
$fielddata['label'] . '<span class="' . $fielddata['phase'] . '"></span>',
|
1180 |
'gtm4wp_admin_output_field',
|
1181 |
GTM4WP_ADMINSLUG,
|
1182 |
GTM4WP_ADMIN_GROUP_ADVANCED,
|
1183 |
array(
|
1184 |
+
'label_for' => 'gtm4wp-options[' . $fieldid . ']',
|
1185 |
+
'description' => $fielddata['description'],
|
1186 |
+
'optionfieldid' => $fieldid,
|
1187 |
+
'plugintocheck' => isset( $fielddata['plugintocheck'] ) ? $fielddata['plugintocheck'] : '',
|
1188 |
)
|
1189 |
);
|
1190 |
}
|
1203 |
GTM4WP_ADMINSLUG,
|
1204 |
GTM4WP_ADMIN_GROUP_CREDITS,
|
1205 |
array(
|
1206 |
+
'label_for' => GTM4WP_ADMIN_GROUP_INFO,
|
1207 |
+
'description' => '<strong>Thomas Geiger</strong><br />
|
1208 |
+
Website: <a href="https://gtm4wp.com/" target="_blank">gtm4wp.com</a><br />
|
1209 |
+
<a href="https://www.linkedin.com/in/duracelltomi" target="_blank">Me on LinkedIn</a><br />
|
1210 |
+
<a href="http://www.linkedin.com/company/jabjab-online-marketing-ltd-" target="_blank">JabJab Online Marketing on LinkedIn</a>',
|
1211 |
)
|
1212 |
);
|
1213 |
|
1214 |
// apply oembed code changes on the admin as well since the oembed call on the admin is cached by WordPress into a transient
|
1215 |
// that is applied on the frontend later
|
1216 |
+
require_once dirname( __FILE__ ) . '/../integration/youtube.php';
|
1217 |
+
require_once dirname( __FILE__ ) . '/../integration/vimeo.php';
|
1218 |
+
require_once dirname( __FILE__ ) . '/../integration/soundcloud.php';
|
1219 |
}
|
1220 |
|
1221 |
function gtm4wp_show_admin_page() {
|
1222 |
global $gtp4wp_plugin_url;
|
1223 |
+
?>
|
1224 |
<div class="wrap">
|
1225 |
<div id="gtm4wp-icon" class="icon32" style="background-image: url(<?php echo $gtp4wp_plugin_url; ?>admin/images/tag_manager-32.png);"><br /></div>
|
1226 |
<h2><?php _e( 'Google Tag Manager for WordPress options', 'duracelltomi-google-tag-manager' ); ?></h2>
|
1227 |
<form action="options.php" method="post">
|
1228 |
+
<?php settings_fields( GTM4WP_ADMIN_GROUP ); ?>
|
1229 |
+
<?php do_settings_sections( GTM4WP_ADMINSLUG ); ?>
|
1230 |
+
<?php submit_button(); ?>
|
1231 |
|
1232 |
</form>
|
1233 |
</div>
|
1234 |
+
<?php
|
1235 |
}
|
1236 |
|
1237 |
function gtm4wp_add_admin_page() {
|
1244 |
);
|
1245 |
}
|
1246 |
|
1247 |
+
function gtm4wp_add_admin_js( $hook ) {
|
1248 |
global $gtp4wp_plugin_url;
|
1249 |
|
1250 |
+
if ( $hook == 'settings_page_' . GTM4WP_ADMINSLUG ) {
|
1251 |
+
wp_register_script( 'admin-subtabs', $gtp4wp_plugin_url . 'js/admin-subtabs.js', array(), GTM4WP_VERSION );
|
1252 |
|
1253 |
$subtabtexts = array(
|
1254 |
+
'posttabtitle' => __( 'Posts', 'duracelltomi-google-tag-manager' ),
|
1255 |
+
'searchtabtitle' => __( 'Search', 'duracelltomi-google-tag-manager' ),
|
1256 |
+
'visitortabtitle' => __( 'Visitors', 'duracelltomi-google-tag-manager' ),
|
1257 |
+
'adwordstabtitle' => __( 'AdWords', 'duracelltomi-google-tag-manager' ),
|
1258 |
+
'browsertabtitle' => __( 'Browser/OS/Device', 'duracelltomi-google-tag-manager' ),
|
1259 |
+
'blocktagstabtitle' => __( 'Blacklist tags', 'duracelltomi-google-tag-manager' ),
|
1260 |
+
'blockmacrostabtitle' => __( 'Blacklist macros', 'duracelltomi-google-tag-manager' ),
|
1261 |
+
'wpcf7tabtitle' => __( 'Contact Form 7', 'duracelltomi-google-tag-manager' ),
|
1262 |
+
'wctabtitle' => __( 'WooCommerce', 'duracelltomi-google-tag-manager' ),
|
1263 |
+
'gotabtitle' => __( 'Google Optimize', 'duracelltomi-google-tag-manager' ),
|
1264 |
+
'amptabtitle' => __( 'Accelerated Mobile Pages', 'duracelltomi-google-tag-manager' ),
|
1265 |
+
'weathertabtitle' => __( 'Weather & geo data', 'duracelltomi-google-tag-manager' ),
|
1266 |
+
'generaleventstabtitle' => __( 'General events', 'duracelltomi-google-tag-manager' ),
|
1267 |
+
'mediaeventstabtitle' => __( 'Media events', 'duracelltomi-google-tag-manager' ),
|
1268 |
+
'depecratedeventstabtitle' => __( 'Deprecated', 'duracelltomi-google-tag-manager' ),
|
1269 |
+
'sitetabtitle' => __( 'Site', 'duracelltomi-google-tag-manager' ),
|
1270 |
+
'misctabtitle' => __( 'Misc', 'duracelltomi-google-tag-manager' ),
|
1271 |
);
|
1272 |
+
wp_localize_script( 'admin-subtabs', 'gtm4wp', $subtabtexts );
|
1273 |
|
1274 |
+
wp_enqueue_script( 'admin-subtabs', array(), GTM4WP_VERSION );
|
1275 |
+
wp_enqueue_script( 'admin-tabcreator', $gtp4wp_plugin_url . 'js/admin-tabcreator.js', array( 'jquery-core' ), GTM4WP_VERSION );
|
1276 |
|
1277 |
+
wp_enqueue_style( 'gtm4wp-validate', $gtp4wp_plugin_url . 'css/admin-gtm4wp.css', array(), GTM4WP_VERSION );
|
1278 |
}
|
1279 |
}
|
1280 |
|
1452 |
global $gtm4wp_options, $gtp4wp_plugin_url, $gtm4wp_integratefieldtexts, $current_user,
|
1453 |
$gtm4wp_def_user_notices_dismisses;
|
1454 |
|
1455 |
+
$woo_plugin_active = is_plugin_active( $gtm4wp_integratefieldtexts[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ]['plugintocheck'] );
|
1456 |
+
if ( $woo_plugin_active && function_exists( 'WC' ) ) {
|
1457 |
$woo = WC();
|
1458 |
} else {
|
1459 |
+
$woo = null;
|
1460 |
}
|
1461 |
|
1462 |
$gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
|
1463 |
+
if ( $gtm4wp_user_notices_dismisses === '' ) {
|
1464 |
+
if ( is_array( $gtm4wp_def_user_notices_dismisses ) ) {
|
1465 |
+
$gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
|
1466 |
+
} else {
|
1467 |
+
$gtm4wp_user_notices_dismisses = array();
|
1468 |
+
}
|
1469 |
} else {
|
1470 |
$gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
|
1471 |
+
if ( false === $gtm4wp_user_notices_dismisses || !is_array( $gtm4wp_user_notices_dismisses ) ) {
|
1472 |
$gtm4wp_user_notices_dismisses = array();
|
1473 |
}
|
1474 |
}
|
1475 |
$gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
|
1476 |
|
1477 |
+
if ( ( trim( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) == '' ) && ( false === $gtm4wp_user_notices_dismisses['enter-gtm-code'] ) ) {
|
1478 |
+
echo '<div class="gtm4wp-notice notice notice-error is-dismissible" data-href="?enter-gtm-code"><p><strong>' . sprintf( __( 'To start using Google Tag Manager for WordPress, please <a href="%s">enter your GTM ID</a>', 'duracelltomi-google-tag-manager' ), 'options-general.php?page=' . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
|
1479 |
}
|
1480 |
|
1481 |
+
if ( (
|
1482 |
+
( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' == $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] )
|
1483 |
) || (
|
1484 |
+
( '' == $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] )
|
1485 |
+
) ) {
|
1486 |
+
echo '<div class="gtm4wp-notice notice notice-error" data-href="?incomplete-gtm-env-config"><p><strong>' . sprintf( __( 'Incomplete Google Tag Manager environment configuration: either gtm_preview or gtm_auth parameter value is missing!', 'duracelltomi-google-tag-manager' ), 'options-general.php?page=' . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
|
1487 |
}
|
1488 |
|
1489 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) || ( false === $gtm4wp_user_notices_dismisses['wc-gayoast-plugin-warning'] ) ) {
|
1490 |
$is_wc_active = $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ||
|
1491 |
$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ||
|
1492 |
$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ];
|
1493 |
|
1494 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) && $is_wc_active && $woo && ( version_compare( $woo->version, '2.1' ) < 0 ) ) {
|
1495 |
+
$woo_ga_options = get_option( 'woocommerce_google_analytics_settings' );
|
1496 |
if ( $woo_ga_options ) {
|
1497 |
+
if ( '' != $woo_ga_options['ga_id'] ) {
|
1498 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-ga-plugin-warning"><p><strong>' . __( 'Notice: you should disable Google Analytics tracking <a href="admin.php?page=wc-settings&tab=integration§ion=google_analytics">in WooCommerce settings</a> by leaving Google Analytics ID field empty if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1499 |
}
|
1500 |
}
|
1501 |
}
|
1502 |
|
1503 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) && $is_wc_active && is_plugin_active( 'woocommerce-google-analytics-integration/woocommerce-google-analytics-integration.php' ) ) {
|
1504 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-ga-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "WooCommerce Google Analytics Integration" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1505 |
}
|
1506 |
|
1507 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['wc-gayoast-plugin-warning'] ) && $is_wc_active && is_plugin_active( 'google-analytics-for-wordpress/googleanalytics.php' ) ) {
|
1508 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-gayoast-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "Google Analytics for WordPress by MonsterInsights" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1509 |
}
|
1510 |
}
|
1511 |
|
1512 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['php56-warning'] ) && ( version_compare( PHP_VERSION, '5.6.0' ) < 0 ) ) {
|
1513 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?php56-warning"><p><strong>' . __( 'Warning: You are using an outdated version of PHP (v' . PHP_VERSION . ') that can cause issues with the plugin Google Tag Manager for WordPress. Please consider to upgrade your PHP.', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1514 |
}
|
1515 |
|
1516 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['woo2x-warning'] ) && ( $woo ) && ( version_compare( $woo->version, '3.0', '<' ) ) ) {
|
1517 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?woo2x-warning"><p><strong>' . __( 'Warning: You are using an outdated version of WooCommerce (v' . $woo->version . '). Google Tag Manager for WordPress will drop support for this version in the near future. Please consider to upgrade.', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1518 |
}
|
1519 |
|
1520 |
+
if ( ( false === $gtm4wp_user_notices_dismisses['deprecated-warning'] ) && (
|
1521 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOCIAL ] ) ||
|
1522 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) ||
|
1523 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) ||
|
1524 |
( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] )
|
1525 |
+
) ) {
|
1526 |
$deprecated_list = array(
|
1527 |
+
'Social actions',
|
1528 |
+
'Outbound link click events',
|
1529 |
+
'Download click events',
|
1530 |
+
'Email click events',
|
1531 |
);
|
1532 |
echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?deprecated-warning"><p><strong>' . __( 'Warning: Some features of Google Tag Manager for WordPress are deprecated and will be removed in the next version: <ul><li>' . implode( '</li><li>', $deprecated_list ) . '</li></ul>', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
|
1533 |
}
|
1537 |
global $gtm4wp_def_user_notices_dismisses, $current_user;
|
1538 |
|
1539 |
$gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
|
1540 |
+
if ( $gtm4wp_user_notices_dismisses === '' ) {
|
1541 |
+
if ( is_array( $gtm4wp_def_user_notices_dismisses ) ) {
|
1542 |
+
$gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
|
1543 |
+
} else {
|
1544 |
+
$gtm4wp_user_notices_dismisses = array();
|
1545 |
+
}
|
1546 |
} else {
|
1547 |
$gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
|
1548 |
+
if ( false === $gtm4wp_user_notices_dismisses || !is_array( $gtm4wp_user_notices_dismisses ) ) {
|
1549 |
$gtm4wp_user_notices_dismisses = array();
|
1550 |
}
|
1551 |
}
|
1552 |
$gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
|
1553 |
|
1554 |
+
$noticeid = trim( basename( $_POST['noticeid'] ) );
|
1555 |
if ( array_key_exists( $noticeid, $gtm4wp_user_notices_dismisses ) ) {
|
1556 |
$gtm4wp_user_notices_dismisses[ $noticeid ] = true;
|
1557 |
update_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, serialize( $gtm4wp_user_notices_dismisses ) );
|
1561 |
function gtm4wp_add_plugin_action_links( $links, $file ) {
|
1562 |
global $gtp4wp_plugin_basename;
|
1563 |
|
1564 |
+
if ( $file != $gtp4wp_plugin_basename ) {
|
1565 |
+
return $links;
|
1566 |
+
}
|
1567 |
|
1568 |
$settings_link = '<a href="' . menu_page_url( GTM4WP_ADMINSLUG, false ) . '">' . esc_html( __( 'Settings' ) ) . '</a>';
|
1569 |
|
1575 |
function gtm4wp_show_upgrade_notification( $current_plugin_metadata, $new_plugin_metadata ) {
|
1576 |
if ( isset( $new_plugin_metadata->upgrade_notice ) && strlen( trim( $new_plugin_metadata->upgrade_notice ) ) > 0 ) {
|
1577 |
echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>Important Upgrade Notice:</strong> ';
|
1578 |
+
echo esc_html( $new_plugin_metadata->upgrade_notice ), '</p>';
|
1579 |
}
|
1580 |
}
|
1581 |
|
1586 |
add_action( 'admin_head', 'gtm4wp_admin_head' );
|
1587 |
add_filter( 'plugin_action_links', 'gtm4wp_add_plugin_action_links', 10, 2 );
|
1588 |
add_action( 'wp_ajax_gtm4wp_dismiss_notice', 'gtm4wp_dismiss_notice' );
|
1589 |
+
add_action( 'in_plugin_update_message-duracelltomi-google-tag-manager-for-wordpress/duracelltomi-google-tag-manager-for-wordpress.php', 'gtm4wp_show_upgrade_notification', 10, 2 );
|
common/readoptions.php
CHANGED
@@ -1,241 +1,251 @@
|
|
1 |
<?php
|
2 |
-
define( 'GTM4WP_OPTIONS',
|
3 |
-
define( 'GTM4WP_OPTION_GTM_CODE',
|
4 |
-
define( 'GTM4WP_OPTION_GTM_PLACEMENT',
|
5 |
-
define( 'GTM4WP_OPTION_DATALAYER_NAME',
|
6 |
-
define( 'GTM4WP_OPTION_ENV_GTM_AUTH',
|
7 |
-
define( 'GTM4WP_OPTION_ENV_GTM_PREVIEW',
|
8 |
-
define( 'GTM4WP_OPTION_DONOTTRACK',
|
9 |
-
define( 'GTM4WP_OPTION_LOADEARLY',
|
10 |
-
|
11 |
-
define( 'GTM4WP_OPTION_INCLUDE_REMARKETING',
|
12 |
-
define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN',
|
13 |
-
define( 'GTM4WP_OPTION_INCLUDE_USERROLE',
|
14 |
-
define( 'GTM4WP_OPTION_INCLUDE_USERID',
|
15 |
-
define( 'GTM4WP_OPTION_INCLUDE_USEREMAIL',
|
16 |
-
define( 'GTM4WP_OPTION_INCLUDE_USERREGDATE',
|
17 |
-
define( 'GTM4WP_OPTION_INCLUDE_USERNAME',
|
18 |
-
define( 'GTM4WP_OPTION_INCLUDE_VISITOR_IP',
|
19 |
-
define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE',
|
20 |
-
define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES',
|
21 |
-
define( 'GTM4WP_OPTION_INCLUDE_TAGS',
|
22 |
-
define( 'GTM4WP_OPTION_INCLUDE_AUTHORID',
|
23 |
-
define( 'GTM4WP_OPTION_INCLUDE_AUTHOR',
|
24 |
-
define( 'GTM4WP_OPTION_INCLUDE_POSTDATE',
|
25 |
-
define( 'GTM4WP_OPTION_INCLUDE_POSTTITLE',
|
26 |
-
define( 'GTM4WP_OPTION_INCLUDE_POSTCOUNT',
|
27 |
-
define( 'GTM4WP_OPTION_INCLUDE_POSTID',
|
28 |
-
define( 'GTM4WP_OPTION_INCLUDE_POSTFORMAT',
|
29 |
-
define( '
|
30 |
-
define( '
|
31 |
-
define( '
|
32 |
-
define( '
|
33 |
-
define( '
|
34 |
-
define( '
|
35 |
-
define( '
|
36 |
-
define( '
|
|
|
|
|
37 |
define( 'GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI', 'weather-openweathermap-apikey' );
|
38 |
-
define( 'GTM4WP_OPTION_INCLUDE_SITEID',
|
39 |
-
define( 'GTM4WP_OPTION_INCLUDE_SITENAME',
|
40 |
|
41 |
-
define( 'GTM4WP_OPTION_EVENTS_OUTBOUND',
|
42 |
-
define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS',
|
43 |
-
define( 'GTM4WP_OPTION_EVENTS_DWLEXT',
|
44 |
-
define( 'GTM4WP_OPTION_EVENTS_EMAILCLICKS',
|
45 |
-
define( 'GTM4WP_OPTION_EVENTS_SOCIAL',
|
46 |
|
47 |
-
define( 'GTM4WP_OPTION_EVENTS_FORMMOVE',
|
48 |
-
define( 'GTM4WP_OPTION_EVENTS_NEWUSERREG',
|
49 |
-
define( 'GTM4WP_OPTION_EVENTS_USERLOGIN',
|
50 |
|
51 |
-
define( 'GTM4WP_OPTION_EVENTS_YOUTUBE',
|
52 |
-
define( 'GTM4WP_OPTION_EVENTS_VIMEO',
|
53 |
-
define( 'GTM4WP_OPTION_EVENTS_SOUNDCLOUD',
|
54 |
|
55 |
-
define( 'GTM4WP_OPTION_SCROLLER_ENABLED',
|
56 |
-
define( 'GTM4WP_OPTION_SCROLLER_DEBUGMODE',
|
57 |
define( 'GTM4WP_OPTION_SCROLLER_CALLBACKTIME', 'scroller-callback-time' );
|
58 |
-
define( 'GTM4WP_OPTION_SCROLLER_DISTANCE',
|
59 |
-
define( 'GTM4WP_OPTION_SCROLLER_CONTENTID',
|
60 |
-
define( 'GTM4WP_OPTION_SCROLLER_READERTIME',
|
61 |
-
|
62 |
-
define( 'GTM4WP_OPTION_BLACKLIST_ENABLE',
|
63 |
-
define( 'GTM4WP_OPTION_BLACKLIST_ADADVISOR',
|
64 |
-
define( 'GTM4WP_OPTION_BLACKLIST_ADROLL',
|
65 |
-
define( 'GTM4WP_OPTION_BLACKLIST_AWCONV',
|
66 |
-
define( 'GTM4WP_OPTION_BLACKLIST_AWREMARKET',
|
67 |
-
define( 'GTM4WP_OPTION_BLACKLIST_BIZO',
|
68 |
-
define( 'GTM4WP_OPTION_BLACKLIST_CLICKTALE',
|
69 |
-
define( 'GTM4WP_OPTION_BLACKLIST_COMSCORE',
|
70 |
-
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMHTML',
|
71 |
-
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMIMG',
|
72 |
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT', 'blacklist-doubleclick-counter' );
|
73 |
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKSALES', 'blacklist-doubleclick-sales' );
|
74 |
-
define( 'GTM4WP_OPTION_BLACKLIST_GACLASSIC',
|
75 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MARIN',
|
76 |
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME', 'blacklist-mediaplex-iframe' );
|
77 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXROI',
|
78 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MEDIA6DEG',
|
79 |
-
define( 'GTM4WP_OPTION_BLACKLIST_TURNCONV',
|
80 |
-
define( 'GTM4WP_OPTION_BLACKLIST_TURNDATA',
|
81 |
-
define( 'GTM4WP_OPTION_BLACKLIST_UA',
|
82 |
-
|
83 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT',
|
84 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS',
|
85 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT',
|
86 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE',
|
87 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME',
|
88 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR',
|
89 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR',
|
90 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM',
|
91 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER',
|
92 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_URL',
|
93 |
-
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT',
|
94 |
|
95 |
define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
|
96 |
|
97 |
-
define( 'GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE',
|
98 |
-
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC',
|
99 |
-
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC',
|
100 |
-
define( '
|
101 |
-
define( '
|
|
|
|
|
|
|
|
|
102 |
define( 'GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH', 'integrate-woocommerce-use-full-category-path' );
|
103 |
-
define( 'GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX',
|
104 |
-
define( '
|
105 |
-
define( '
|
106 |
-
define( '
|
107 |
-
define( '
|
108 |
-
|
109 |
-
|
110 |
-
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS', 'integrate-google-optimize-idlist' );
|
111 |
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT', 'integrate-google-optimize-timeout' );
|
112 |
-
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID',
|
113 |
|
114 |
define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );
|
115 |
|
116 |
define( 'GTM4WP_OPTION_INTEGRATE_AMPID', 'integrate-amp-id' );
|
117 |
|
118 |
-
define( 'GTM4WP_PLACEMENT_FOOTER',
|
119 |
-
define( 'GTM4WP_PLACEMENT_BODYOPEN',
|
120 |
define( 'GTM4WP_PLACEMENT_BODYOPEN_AUTO', 2 );
|
121 |
-
define( 'GTM4WP_PLACEMENT_OFF',
|
122 |
|
123 |
$gtm4wp_options = array();
|
124 |
|
125 |
$gtm4wp_defaultoptions = array(
|
126 |
-
GTM4WP_OPTION_GTM_CODE
|
127 |
-
GTM4WP_OPTION_DATALAYER_NAME
|
128 |
-
GTM4WP_OPTION_GTM_PLACEMENT
|
129 |
-
GTM4WP_OPTION_ENV_GTM_AUTH
|
130 |
-
GTM4WP_OPTION_ENV_GTM_PREVIEW
|
131 |
-
GTM4WP_OPTION_DONOTTRACK
|
132 |
-
GTM4WP_OPTION_LOADEARLY
|
133 |
-
|
134 |
-
GTM4WP_OPTION_INCLUDE_REMARKETING
|
135 |
-
GTM4WP_OPTION_INCLUDE_LOGGEDIN
|
136 |
-
GTM4WP_OPTION_INCLUDE_USERROLE
|
137 |
-
GTM4WP_OPTION_INCLUDE_USERID
|
138 |
-
GTM4WP_OPTION_INCLUDE_USEREMAIL
|
139 |
-
GTM4WP_OPTION_INCLUDE_USERREGDATE
|
140 |
-
GTM4WP_OPTION_INCLUDE_USERNAME
|
141 |
-
GTM4WP_OPTION_INCLUDE_VISITOR_IP
|
142 |
-
GTM4WP_OPTION_INCLUDE_POSTTYPE
|
143 |
-
GTM4WP_OPTION_INCLUDE_CATEGORIES
|
144 |
-
GTM4WP_OPTION_INCLUDE_TAGS
|
145 |
-
GTM4WP_OPTION_INCLUDE_AUTHOR
|
146 |
-
GTM4WP_OPTION_INCLUDE_AUTHORID
|
147 |
-
GTM4WP_OPTION_INCLUDE_POSTDATE
|
148 |
-
GTM4WP_OPTION_INCLUDE_POSTTITLE
|
149 |
-
GTM4WP_OPTION_INCLUDE_POSTCOUNT
|
150 |
-
GTM4WP_OPTION_INCLUDE_POSTID
|
151 |
-
GTM4WP_OPTION_INCLUDE_POSTFORMAT
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
219 |
|
220 |
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => false,
|
221 |
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => false,
|
|
|
|
|
|
|
|
|
222 |
GTM4WP_OPTION_INTEGRATE_WCREMARKETING => false,
|
223 |
GTM4WP_OPTION_INTEGRATE_WCUSESKU => false,
|
224 |
GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH => false,
|
225 |
-
GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX =>
|
226 |
-
GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP => false,
|
227 |
GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => false,
|
228 |
GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => false,
|
229 |
-
|
230 |
GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => false,
|
231 |
|
232 |
-
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS =>
|
233 |
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => 4000,
|
234 |
-
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID =>
|
235 |
|
236 |
-
GTM4WP_OPTION_INTEGRATE_WPECOMMERCE
|
237 |
|
238 |
-
GTM4WP_OPTION_INTEGRATE_AMPID
|
239 |
);
|
240 |
|
241 |
function gtm4wp_reload_options() {
|
@@ -259,11 +269,11 @@ function gtm4wp_reload_options() {
|
|
259 |
}
|
260 |
|
261 |
function gtp4wp_debug_file( $debug_data ) {
|
262 |
-
$fp = fopen( dirname( __FILE__ ) .
|
263 |
if ( $fp ) {
|
264 |
fwrite( $fp, $debug_data );
|
265 |
fclose( $fp );
|
266 |
}
|
267 |
}
|
268 |
|
269 |
-
$gtm4wp_options = gtm4wp_reload_options();
|
1 |
<?php
|
2 |
+
define( 'GTM4WP_OPTIONS', 'gtm4wp-options' );
|
3 |
+
define( 'GTM4WP_OPTION_GTM_CODE', 'gtm-code' );
|
4 |
+
define( 'GTM4WP_OPTION_GTM_PLACEMENT', 'gtm-code-placement' );
|
5 |
+
define( 'GTM4WP_OPTION_DATALAYER_NAME', 'gtm-datalayer-variable-name' );
|
6 |
+
define( 'GTM4WP_OPTION_ENV_GTM_AUTH', 'gtm-env-gtm-auth' );
|
7 |
+
define( 'GTM4WP_OPTION_ENV_GTM_PREVIEW', 'gtm-env-gtm-preview' );
|
8 |
+
define( 'GTM4WP_OPTION_DONOTTRACK', 'gtm-browser-do-not-track' );
|
9 |
+
define( 'GTM4WP_OPTION_LOADEARLY', 'gtm-load-gtm-early' );
|
10 |
+
|
11 |
+
define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
|
12 |
+
define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN', 'include-loggedin' );
|
13 |
+
define( 'GTM4WP_OPTION_INCLUDE_USERROLE', 'include-userrole' );
|
14 |
+
define( 'GTM4WP_OPTION_INCLUDE_USERID', 'include-userid' );
|
15 |
+
define( 'GTM4WP_OPTION_INCLUDE_USEREMAIL', 'include-useremail' );
|
16 |
+
define( 'GTM4WP_OPTION_INCLUDE_USERREGDATE', 'include-userregdate' );
|
17 |
+
define( 'GTM4WP_OPTION_INCLUDE_USERNAME', 'include-username' );
|
18 |
+
define( 'GTM4WP_OPTION_INCLUDE_VISITOR_IP', 'include-visitor-ip' );
|
19 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE', 'include-posttype' );
|
20 |
+
define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES', 'include-categories' );
|
21 |
+
define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
|
22 |
+
define( 'GTM4WP_OPTION_INCLUDE_AUTHORID', 'include-authorid' );
|
23 |
+
define( 'GTM4WP_OPTION_INCLUDE_AUTHOR', 'include-author' );
|
24 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTDATE', 'include-postdate' );
|
25 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTTITLE', 'include-posttitle' );
|
26 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTCOUNT', 'include-postcount' );
|
27 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTID', 'include-postid' );
|
28 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTFORMAT', 'include-postformat' );
|
29 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTTERMLIST', 'include-postterms' );
|
30 |
+
define( 'GTM4WP_OPTION_INCLUDE_SEARCHDATA', 'include-searchdata' );
|
31 |
+
define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
|
32 |
+
define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
|
33 |
+
define( 'GTM4WP_OPTION_INCLUDE_DEVICEDATA', 'include-devicedata' );
|
34 |
+
define( 'GTM4WP_OPTION_INCLUDE_MISCGEO', 'include-miscgeo' );
|
35 |
+
define( 'GTM4WP_OPTION_INCLUDE_MISCGEOAPI', 'geo-apikey' );
|
36 |
+
define( 'GTM4WP_OPTION_INCLUDE_MISCGEOCF', 'include-miscgeo-cloudflare' );
|
37 |
+
define( 'GTM4WP_OPTION_INCLUDE_WEATHER', 'include-weather' );
|
38 |
+
define( 'GTM4WP_OPTION_INCLUDE_WEATHERUNITS', 'weather-weatherunits' );
|
39 |
define( 'GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI', 'weather-openweathermap-apikey' );
|
40 |
+
define( 'GTM4WP_OPTION_INCLUDE_SITEID', 'include-siteid' );
|
41 |
+
define( 'GTM4WP_OPTION_INCLUDE_SITENAME', 'include-sitename' );
|
42 |
|
43 |
+
define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
|
44 |
+
define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
|
45 |
+
define( 'GTM4WP_OPTION_EVENTS_DWLEXT', 'event-download-extensions' );
|
46 |
+
define( 'GTM4WP_OPTION_EVENTS_EMAILCLICKS', 'event-email-clicks' );
|
47 |
+
define( 'GTM4WP_OPTION_EVENTS_SOCIAL', 'event-social' );
|
48 |
|
49 |
+
define( 'GTM4WP_OPTION_EVENTS_FORMMOVE', 'event-form-move' );
|
50 |
+
define( 'GTM4WP_OPTION_EVENTS_NEWUSERREG', 'event-new-user-registration' );
|
51 |
+
define( 'GTM4WP_OPTION_EVENTS_USERLOGIN', 'event-user-logged-in' );
|
52 |
|
53 |
+
define( 'GTM4WP_OPTION_EVENTS_YOUTUBE', 'event-youtube' );
|
54 |
+
define( 'GTM4WP_OPTION_EVENTS_VIMEO', 'event-vimeo' );
|
55 |
+
define( 'GTM4WP_OPTION_EVENTS_SOUNDCLOUD', 'event-soundcloud' );
|
56 |
|
57 |
+
define( 'GTM4WP_OPTION_SCROLLER_ENABLED', 'scroller-enabled' );
|
58 |
+
define( 'GTM4WP_OPTION_SCROLLER_DEBUGMODE', 'scroller-debug-mode' );
|
59 |
define( 'GTM4WP_OPTION_SCROLLER_CALLBACKTIME', 'scroller-callback-time' );
|
60 |
+
define( 'GTM4WP_OPTION_SCROLLER_DISTANCE', 'scroller-distance' );
|
61 |
+
define( 'GTM4WP_OPTION_SCROLLER_CONTENTID', 'scroller-contentid' );
|
62 |
+
define( 'GTM4WP_OPTION_SCROLLER_READERTIME', 'scroller-readertime' );
|
63 |
+
|
64 |
+
define( 'GTM4WP_OPTION_BLACKLIST_ENABLE', 'blacklist-enable' );
|
65 |
+
define( 'GTM4WP_OPTION_BLACKLIST_ADADVISOR', 'blacklist-adadvisor' );
|
66 |
+
define( 'GTM4WP_OPTION_BLACKLIST_ADROLL', 'blacklist-adroll' );
|
67 |
+
define( 'GTM4WP_OPTION_BLACKLIST_AWCONV', 'blacklist-adwords-conversion' );
|
68 |
+
define( 'GTM4WP_OPTION_BLACKLIST_AWREMARKET', 'blacklist-adwords-remarketing' );
|
69 |
+
define( 'GTM4WP_OPTION_BLACKLIST_BIZO', 'blacklist-bizo' );
|
70 |
+
define( 'GTM4WP_OPTION_BLACKLIST_CLICKTALE', 'blacklist-clicktale' );
|
71 |
+
define( 'GTM4WP_OPTION_BLACKLIST_COMSCORE', 'blacklist-comscore' );
|
72 |
+
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMHTML', 'blacklist-custom-html' );
|
73 |
+
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMIMG', 'blacklist-custom-img-tag' );
|
74 |
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT', 'blacklist-doubleclick-counter' );
|
75 |
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKSALES', 'blacklist-doubleclick-sales' );
|
76 |
+
define( 'GTM4WP_OPTION_BLACKLIST_GACLASSIC', 'blacklist-google-analytics' );
|
77 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MARIN', 'blacklist-marin' );
|
78 |
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME', 'blacklist-mediaplex-iframe' );
|
79 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXROI', 'blacklist-mediaplex-roi' );
|
80 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MEDIA6DEG', 'blacklist-media6degrees' );
|
81 |
+
define( 'GTM4WP_OPTION_BLACKLIST_TURNCONV', 'blacklist-turn-conversion' );
|
82 |
+
define( 'GTM4WP_OPTION_BLACKLIST_TURNDATA', 'blacklist-turn-data' );
|
83 |
+
define( 'GTM4WP_OPTION_BLACKLIST_UA', 'blacklist-universal-analytics' );
|
84 |
+
|
85 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT', 'blacklist-macro-dom-element' );
|
86 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS', 'blacklist-macro-custom-js' );
|
87 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT', 'blacklist-macro-constant-string' );
|
88 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE', 'blacklist-macro-1st-party-cookie' );
|
89 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME', 'blacklist-macro-event-name' );
|
90 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR', 'blacklist-macro-javascript-variable' );
|
91 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR', 'blacklist-macro-datalayer-variable' );
|
92 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM', 'blacklist-macro-random-number' );
|
93 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER', 'blacklist-macro-referrer' );
|
94 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_URL', 'blacklist-macro-url' );
|
95 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT', 'blacklist-macro-autoevent-variable' );
|
96 |
|
97 |
define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
|
98 |
|
99 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE', 'integrate-woocommerce' );
|
100 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC', 'integrate-woocommerce-track-classic-ecommerce' );
|
101 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC', 'integrate-woocommerce-track-enhanced-ecommerce' );
|
102 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION', 'integrate-woocommerce-product-per-impression' );
|
103 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP', 'integrate-woocommerce-cart-as-first-step' );
|
104 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL', 'integrate-woocommerce-cart-content-in-datalayer' );
|
105 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY', 'integrate-woocommerce-brand-taxonomy' );
|
106 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCREMARKETING', 'integrate-woocommerce-remarketing' );
|
107 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCUSESKU', 'integrate-woocommerce-remarketing-usesku' );
|
108 |
define( 'GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH', 'integrate-woocommerce-use-full-category-path' );
|
109 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX', 'integrate-woocommerce-remarketing-productidprefix' );
|
110 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA', 'integrate-woocommerce-customer-data' );
|
111 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX', 'integrate-woocommerce-exclude-tax' );
|
112 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING', 'integrate-woocommerce-exclude-shipping' );
|
113 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG', 'integrate-woocommerce-do-not-use-order-tracked-flag' );
|
114 |
+
|
115 |
+
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS', 'integrate-google-optimize-idlist' );
|
|
|
116 |
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT', 'integrate-google-optimize-timeout' );
|
117 |
+
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID', 'integrate-google-optimize-gaid' );
|
118 |
|
119 |
define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );
|
120 |
|
121 |
define( 'GTM4WP_OPTION_INTEGRATE_AMPID', 'integrate-amp-id' );
|
122 |
|
123 |
+
define( 'GTM4WP_PLACEMENT_FOOTER', 0 );
|
124 |
+
define( 'GTM4WP_PLACEMENT_BODYOPEN', 1 );
|
125 |
define( 'GTM4WP_PLACEMENT_BODYOPEN_AUTO', 2 );
|
126 |
+
define( 'GTM4WP_PLACEMENT_OFF', 3 );
|
127 |
|
128 |
$gtm4wp_options = array();
|
129 |
|
130 |
$gtm4wp_defaultoptions = array(
|
131 |
+
GTM4WP_OPTION_GTM_CODE => '',
|
132 |
+
GTM4WP_OPTION_DATALAYER_NAME => '',
|
133 |
+
GTM4WP_OPTION_GTM_PLACEMENT => GTM4WP_PLACEMENT_FOOTER,
|
134 |
+
GTM4WP_OPTION_ENV_GTM_AUTH => '',
|
135 |
+
GTM4WP_OPTION_ENV_GTM_PREVIEW => '',
|
136 |
+
GTM4WP_OPTION_DONOTTRACK => false,
|
137 |
+
GTM4WP_OPTION_LOADEARLY => false,
|
138 |
+
|
139 |
+
GTM4WP_OPTION_INCLUDE_REMARKETING => false,
|
140 |
+
GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
|
141 |
+
GTM4WP_OPTION_INCLUDE_USERROLE => false,
|
142 |
+
GTM4WP_OPTION_INCLUDE_USERID => false,
|
143 |
+
GTM4WP_OPTION_INCLUDE_USEREMAIL => false,
|
144 |
+
GTM4WP_OPTION_INCLUDE_USERREGDATE => false,
|
145 |
+
GTM4WP_OPTION_INCLUDE_USERNAME => false,
|
146 |
+
GTM4WP_OPTION_INCLUDE_VISITOR_IP => false,
|
147 |
+
GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
|
148 |
+
GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
|
149 |
+
GTM4WP_OPTION_INCLUDE_TAGS => true,
|
150 |
+
GTM4WP_OPTION_INCLUDE_AUTHOR => true,
|
151 |
+
GTM4WP_OPTION_INCLUDE_AUTHORID => false,
|
152 |
+
GTM4WP_OPTION_INCLUDE_POSTDATE => false,
|
153 |
+
GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
|
154 |
+
GTM4WP_OPTION_INCLUDE_POSTCOUNT => false,
|
155 |
+
GTM4WP_OPTION_INCLUDE_POSTID => false,
|
156 |
+
GTM4WP_OPTION_INCLUDE_POSTFORMAT => false,
|
157 |
+
GTM4WP_OPTION_INCLUDE_POSTTERMLIST => false,
|
158 |
+
GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
|
159 |
+
GTM4WP_OPTION_INCLUDE_BROWSERDATA => false,
|
160 |
+
GTM4WP_OPTION_INCLUDE_OSDATA => false,
|
161 |
+
GTM4WP_OPTION_INCLUDE_DEVICEDATA => false,
|
162 |
+
GTM4WP_OPTION_INCLUDE_MISCGEO => false,
|
163 |
+
GTM4WP_OPTION_INCLUDE_MISCGEOAPI => '',
|
164 |
+
GTM4WP_OPTION_INCLUDE_MISCGEOCF => false,
|
165 |
+
GTM4WP_OPTION_INCLUDE_WEATHER => false,
|
166 |
+
GTM4WP_OPTION_INCLUDE_WEATHERUNITS => 0,
|
167 |
+
GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => '',
|
168 |
+
GTM4WP_OPTION_INCLUDE_SITEID => false,
|
169 |
+
GTM4WP_OPTION_INCLUDE_SITENAME => false,
|
170 |
+
|
171 |
+
GTM4WP_OPTION_EVENTS_OUTBOUND => false,
|
172 |
+
GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
|
173 |
+
GTM4WP_OPTION_EVENTS_DWLEXT => 'pdf,doc,docx,xls,xlsx,ppt,pptx,zip,rar,gz,tar',
|
174 |
+
GTM4WP_OPTION_EVENTS_EMAILCLICKS => false,
|
175 |
+
GTM4WP_OPTION_EVENTS_SOCIAL => false,
|
176 |
+
|
177 |
+
GTM4WP_OPTION_EVENTS_FORMMOVE => true,
|
178 |
+
GTM4WP_OPTION_EVENTS_NEWUSERREG => false,
|
179 |
+
GTM4WP_OPTION_EVENTS_USERLOGIN => false,
|
180 |
+
|
181 |
+
GTM4WP_OPTION_EVENTS_YOUTUBE => false,
|
182 |
+
GTM4WP_OPTION_EVENTS_VIMEO => false,
|
183 |
+
GTM4WP_OPTION_EVENTS_SOUNDCLOUD => false,
|
184 |
+
|
185 |
+
GTM4WP_OPTION_SCROLLER_ENABLED => false,
|
186 |
+
GTM4WP_OPTION_SCROLLER_DEBUGMODE => false,
|
187 |
+
GTM4WP_OPTION_SCROLLER_CALLBACKTIME => 100,
|
188 |
+
GTM4WP_OPTION_SCROLLER_DISTANCE => 150,
|
189 |
+
GTM4WP_OPTION_SCROLLER_CONTENTID => 'content',
|
190 |
+
GTM4WP_OPTION_SCROLLER_READERTIME => 60,
|
191 |
+
|
192 |
+
GTM4WP_OPTION_BLACKLIST_ENABLE => 0,
|
193 |
+
GTM4WP_OPTION_BLACKLIST_ADADVISOR => false,
|
194 |
+
GTM4WP_OPTION_BLACKLIST_ADROLL => false,
|
195 |
+
GTM4WP_OPTION_BLACKLIST_AWCONV => false,
|
196 |
+
GTM4WP_OPTION_BLACKLIST_AWREMARKET => false,
|
197 |
+
GTM4WP_OPTION_BLACKLIST_BIZO => false,
|
198 |
+
GTM4WP_OPTION_BLACKLIST_CLICKTALE => false,
|
199 |
+
GTM4WP_OPTION_BLACKLIST_COMSCORE => false,
|
200 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMHTML => false,
|
201 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMIMG => false,
|
202 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT => false,
|
203 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKSALES => false,
|
204 |
+
GTM4WP_OPTION_BLACKLIST_GACLASSIC => false,
|
205 |
+
GTM4WP_OPTION_BLACKLIST_MARIN => false,
|
206 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME => false,
|
207 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXROI => false,
|
208 |
+
GTM4WP_OPTION_BLACKLIST_MEDIA6DEG => false,
|
209 |
+
GTM4WP_OPTION_BLACKLIST_TURNCONV => false,
|
210 |
+
GTM4WP_OPTION_BLACKLIST_TURNDATA => false,
|
211 |
+
GTM4WP_OPTION_BLACKLIST_UA => false,
|
212 |
+
|
213 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT => true,
|
214 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS => true,
|
215 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT => true,
|
216 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE => true,
|
217 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME => true,
|
218 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR => true,
|
219 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR => true,
|
220 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM => true,
|
221 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER => true,
|
222 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_URL => true,
|
223 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT => true,
|
224 |
+
|
225 |
+
GTM4WP_OPTION_INTEGRATE_WPCF7 => false,
|
226 |
|
227 |
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => false,
|
228 |
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => false,
|
229 |
+
GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION => 0,
|
230 |
+
GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP => false,
|
231 |
+
GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL => false,
|
232 |
+
GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY => '',
|
233 |
GTM4WP_OPTION_INTEGRATE_WCREMARKETING => false,
|
234 |
GTM4WP_OPTION_INTEGRATE_WCUSESKU => false,
|
235 |
GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH => false,
|
236 |
+
GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => '',
|
|
|
237 |
GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => false,
|
238 |
GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => false,
|
239 |
+
GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => false,
|
240 |
GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => false,
|
241 |
|
242 |
+
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => '',
|
243 |
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => 4000,
|
244 |
+
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID => '',
|
245 |
|
246 |
+
GTM4WP_OPTION_INTEGRATE_WPECOMMERCE => false,
|
247 |
|
248 |
+
GTM4WP_OPTION_INTEGRATE_AMPID => ''
|
249 |
);
|
250 |
|
251 |
function gtm4wp_reload_options() {
|
269 |
}
|
270 |
|
271 |
function gtp4wp_debug_file( $debug_data ) {
|
272 |
+
$fp = fopen( dirname( __FILE__ ) . '/' . date( 'Y-m-d-H-i-s-u' ) . '.txt', 'w' );
|
273 |
if ( $fp ) {
|
274 |
fwrite( $fp, $debug_data );
|
275 |
fclose( $fp );
|
276 |
}
|
277 |
}
|
278 |
|
279 |
+
$gtm4wp_options = gtm4wp_reload_options();
|
css/admin-gtm4wp.css
CHANGED
@@ -1,72 +1,72 @@
|
|
1 |
-
.tabinfo {
|
2 |
-
display: block;
|
3 |
-
clear: both;
|
4 |
-
margin: 20px 10px;
|
5 |
-
}
|
6 |
-
|
7 |
-
.gtm4wp-plugin-active {
|
8 |
-
color: #0c0;
|
9 |
-
}
|
10 |
-
|
11 |
-
.gtm4wp-plugin-not-active {
|
12 |
-
color: #c00;
|
13 |
-
}
|
14 |
-
|
15 |
-
.adminsubtabs {
|
16 |
-
list-style: none;
|
17 |
-
margin: 16px 0;
|
18 |
-
padding: 0;
|
19 |
-
font-size: 13px;
|
20 |
-
float: left;
|
21 |
-
color: #666;
|
22 |
-
}
|
23 |
-
|
24 |
-
.adminsubtabs li {
|
25 |
-
display: inline-block;
|
26 |
-
margin: 0;
|
27 |
-
padding: 0 10px;
|
28 |
-
white-space: nowrap;
|
29 |
-
border-right: 1px solid #666;
|
30 |
-
}
|
31 |
-
|
32 |
-
.adminsubtabs li:last-child {
|
33 |
-
border-right: 0;
|
34 |
-
}
|
35 |
-
|
36 |
-
.adminsubtabs a {
|
37 |
-
padding: .2em;
|
38 |
-
text-decoration: none;
|
39 |
-
}
|
40 |
-
|
41 |
-
.adminsubtabs a.subtab-active {
|
42 |
-
color: #000;
|
43 |
-
font-weight: bold;
|
44 |
-
}
|
45 |
-
|
46 |
-
.gtm4wp-phase-beta,
|
47 |
-
.gtm4wp-phase-experimental,
|
48 |
-
.gtm4wp-phase-deprecated {
|
49 |
-
display: inline-block;
|
50 |
-
background-color: #f00;
|
51 |
-
color: #fff;
|
52 |
-
font-size: 9px;
|
53 |
-
padding: 2px;
|
54 |
-
margin-left: 5px;
|
55 |
-
}
|
56 |
-
|
57 |
-
.gtm4wp-phase-beta:before {
|
58 |
-
content: "beta";
|
59 |
-
}
|
60 |
-
|
61 |
-
.gtm4wp-phase-deprecated {
|
62 |
-
background-color: #ddd;
|
63 |
-
color: #000;
|
64 |
-
}
|
65 |
-
|
66 |
-
.gtm4wp-phase-experimental:before {
|
67 |
-
content: "experimental";
|
68 |
-
}
|
69 |
-
|
70 |
-
.gtm4wp-phase-deprecated:before {
|
71 |
-
content: "deprecated";
|
72 |
}
|
1 |
+
.tabinfo {
|
2 |
+
display: block;
|
3 |
+
clear: both;
|
4 |
+
margin: 20px 10px;
|
5 |
+
}
|
6 |
+
|
7 |
+
.gtm4wp-plugin-active {
|
8 |
+
color: #0c0;
|
9 |
+
}
|
10 |
+
|
11 |
+
.gtm4wp-plugin-not-active {
|
12 |
+
color: #c00;
|
13 |
+
}
|
14 |
+
|
15 |
+
.adminsubtabs {
|
16 |
+
list-style: none;
|
17 |
+
margin: 16px 0;
|
18 |
+
padding: 0;
|
19 |
+
font-size: 13px;
|
20 |
+
float: left;
|
21 |
+
color: #666;
|
22 |
+
}
|
23 |
+
|
24 |
+
.adminsubtabs li {
|
25 |
+
display: inline-block;
|
26 |
+
margin: 0;
|
27 |
+
padding: 0 10px;
|
28 |
+
white-space: nowrap;
|
29 |
+
border-right: 1px solid #666;
|
30 |
+
}
|
31 |
+
|
32 |
+
.adminsubtabs li:last-child {
|
33 |
+
border-right: 0;
|
34 |
+
}
|
35 |
+
|
36 |
+
.adminsubtabs a {
|
37 |
+
padding: .2em;
|
38 |
+
text-decoration: none;
|
39 |
+
}
|
40 |
+
|
41 |
+
.adminsubtabs a.subtab-active {
|
42 |
+
color: #000;
|
43 |
+
font-weight: bold;
|
44 |
+
}
|
45 |
+
|
46 |
+
.gtm4wp-phase-beta,
|
47 |
+
.gtm4wp-phase-experimental,
|
48 |
+
.gtm4wp-phase-deprecated {
|
49 |
+
display: inline-block;
|
50 |
+
background-color: #f00;
|
51 |
+
color: #fff;
|
52 |
+
font-size: 9px;
|
53 |
+
padding: 2px;
|
54 |
+
margin-left: 5px;
|
55 |
+
}
|
56 |
+
|
57 |
+
.gtm4wp-phase-beta:before {
|
58 |
+
content: "beta";
|
59 |
+
}
|
60 |
+
|
61 |
+
.gtm4wp-phase-deprecated {
|
62 |
+
background-color: #ddd;
|
63 |
+
color: #000;
|
64 |
+
}
|
65 |
+
|
66 |
+
.gtm4wp-phase-experimental:before {
|
67 |
+
content: "experimental";
|
68 |
+
}
|
69 |
+
|
70 |
+
.gtm4wp-phase-deprecated:before {
|
71 |
+
content: "deprecated";
|
72 |
}
|
duracelltomi-google-tag-manager-for-wordpress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Google Tag Manager for Wordpress
|
4 |
-
Version: 1.
|
5 |
Plugin URI: https://gtm4wp.com/
|
6 |
Description: The first Google Tag Manager plugin for WordPress with business goals in mind
|
7 |
Author: Thomas Geiger
|
@@ -10,22 +10,22 @@ Text Domain: duracelltomi-google-tag-manager
|
|
10 |
Domain Path: /languages
|
11 |
|
12 |
WC requires at least: 2.6
|
13 |
-
WC tested up to: 3.5
|
14 |
*/
|
15 |
|
16 |
-
define( 'GTM4WP_VERSION', '1.
|
17 |
define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
|
18 |
|
19 |
-
$gtp4wp_plugin_url
|
20 |
$gtp4wp_plugin_basename = plugin_basename( __FILE__ );
|
21 |
-
require_once
|
22 |
|
23 |
function gtm4wp_init() {
|
24 |
load_plugin_textdomain( 'duracelltomi-google-tag-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
25 |
if ( is_admin() ) {
|
26 |
-
require_once
|
27 |
} else {
|
28 |
-
require_once
|
29 |
}
|
30 |
}
|
31 |
-
add_action('plugins_loaded', 'gtm4wp_init');
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Google Tag Manager for Wordpress
|
4 |
+
Version: 1.10
|
5 |
Plugin URI: https://gtm4wp.com/
|
6 |
Description: The first Google Tag Manager plugin for WordPress with business goals in mind
|
7 |
Author: Thomas Geiger
|
10 |
Domain Path: /languages
|
11 |
|
12 |
WC requires at least: 2.6
|
13 |
+
WC tested up to: 3.6.5
|
14 |
*/
|
15 |
|
16 |
+
define( 'GTM4WP_VERSION', '1.10' );
|
17 |
define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
|
18 |
|
19 |
+
$gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
|
20 |
$gtp4wp_plugin_basename = plugin_basename( __FILE__ );
|
21 |
+
require_once GTM4WP_PATH . '/common/readoptions.php';
|
22 |
|
23 |
function gtm4wp_init() {
|
24 |
load_plugin_textdomain( 'duracelltomi-google-tag-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
25 |
if ( is_admin() ) {
|
26 |
+
require_once GTM4WP_PATH . '/admin/admin.php';
|
27 |
} else {
|
28 |
+
require_once GTM4WP_PATH . '/public/frontend.php';
|
29 |
}
|
30 |
}
|
31 |
+
add_action( 'plugins_loaded', 'gtm4wp_init' );
|
integration/amp.php
CHANGED
@@ -1,25 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* AMP (Accelerated Mobile Pages Support) for gtm4wp
|
4 |
-
*
|
5 |
-
* This intergration added AMP support when using amp-wp, the existing dataLayer used
|
6 |
-
* for Google Tag Manager on HTML is loaded and built into AMP compatible code.
|
7 |
-
*
|
8 |
-
* @author
|
9 |
-
* @package
|
10 |
-
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
-
* Todo's
|
15 |
-
*
|
16 |
-
* - Better handling of gtm4wp_amp_gtmampcode_check() to allow for other plugins
|
17 |
-
* - Develop array's into strings as AMP GTM dose not allow custom js variables
|
18 |
-
* - Better Client ID support (https://github.com/Automattic/amp-wp/issues/775)
|
19 |
-
* - Update AMP cache on GTM changes (https://github.com/Automattic/amp-wp/pull/605)
|
20 |
-
* - Supporting PWA with SuperPWA intergration with AMP and PWA for offline
|
21 |
-
|
22 |
-
*/
|
23 |
|
24 |
|
25 |
/**
|
@@ -28,7 +27,7 @@
|
|
28 |
* @author Vincent Koc <https://github.com/koconder/>
|
29 |
* @return bool Returns true if we are running on an AMP page
|
30 |
*/
|
31 |
-
function gtm4wp_amp_running(){
|
32 |
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
|
33 |
return true;
|
34 |
}
|
@@ -46,13 +45,18 @@ function gtm4wp_amp_running(){
|
|
46 |
function gtm4wp_amp_gtmampcode_check( $data ) {
|
47 |
global $gtm4wp_amp_headerinjected;
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
// AMP-WP Plugin
|
50 |
if ( ! empty( $data['amp_analytics'] ) ) {
|
51 |
// Inject into AMP Plugin to load
|
52 |
-
$data[
|
53 |
-
$gtm4wp_amp_headerinjected
|
54 |
|
55 |
-
|
56 |
} else {
|
57 |
// Inject manually based on AMP <head> hook
|
58 |
add_action( 'amp_post_template_head', 'gtm4wp_amp_gtmampcode_injecthead' );
|
@@ -82,13 +86,19 @@ function gtm4wp_amp_gtmampcode_injecthead() {
|
|
82 |
* @return int Returns number of injected snippets, false if no injection
|
83 |
*/
|
84 |
function gtm4wp_amp_gtmcode() {
|
85 |
-
global $gtm4wp_datalayer_json, $gtm4wp_options;
|
|
|
|
|
|
|
|
|
|
|
86 |
|
|
|
87 |
// Check dataLayer is loaded from the plugin
|
88 |
-
if( !empty( $gtm4wp_datalayer_json ) ) {
|
89 |
|
90 |
// Builds a list of GTM id's
|
91 |
-
$gtm4wp_ampids
|
92 |
$gtm4wp_ampid_list = array();
|
93 |
|
94 |
// Counter used for status return
|
@@ -98,21 +108,20 @@ function gtm4wp_amp_gtmcode() {
|
|
98 |
if ( count( $gtm4wp_ampids ) > 0 ) {
|
99 |
|
100 |
// Loop through each GTM idea and build the AMP GTM code
|
101 |
-
foreach( $gtm4wp_ampids as $gtm4wp_oneampid ) {
|
102 |
|
103 |
// Docs: https://developers.google.com/analytics/devguides/collection/amp-analytics/
|
104 |
// Examples: from https://www.simoahava.com/analytics/accelerated-mobile-pages-via-google-tag-manager/
|
105 |
-
|
106 |
// Inject the AMP GTM code
|
107 |
// TODO: Use AMP classes to enable cross-compatibility with other future plugins
|
108 |
-
echo '<!-- Google Tag Manager --><amp-analytics config="https://www.googletagmanager.com/amp.json?id='
|
109 |
|
110 |
// Add to counter
|
111 |
$x++;
|
112 |
}
|
113 |
|
114 |
// Check how many injections for return
|
115 |
-
if( $x > 0 ) {
|
116 |
return $x;
|
117 |
}
|
118 |
}
|
@@ -130,23 +139,23 @@ function gtm4wp_amp_gtmcode() {
|
|
130 |
*/
|
131 |
function gtm4wp_amp_gtmvariables() {
|
132 |
global $gtm4wp_datalayer_json;
|
133 |
-
return '{"vars":{'
|
134 |
}
|
135 |
|
136 |
|
137 |
// Set Status at start
|
138 |
$gtm4wp_amp_headerinjected = false;
|
|
|
139 |
|
140 |
// Load AMP-Analytics tag into <head>
|
141 |
add_action( 'amp_post_template_data', 'gtm4wp_amp_gtmampcode_check' );
|
142 |
|
143 |
// Load the GTM code processing to gain the GTM DataLayer
|
144 |
-
add_action( 'amp_post_template_head', 'gtm4wp_wp_header_begin');
|
145 |
add_action( 'amp_post_template_head', 'gtm4wp_wp_header_top', 1 );
|
146 |
|
147 |
-
//Try
|
148 |
-
//(https://github.com/Automattic/amp-wp/pull/1143)
|
149 |
-
|
150 |
-
|
151 |
// Publish the GTM code and dataLayer to the footer
|
152 |
-
add_action( 'amp_post_template_footer', 'gtm4wp_amp_gtmcode');
|
1 |
<?php
|
2 |
/**
|
3 |
+
* AMP (Accelerated Mobile Pages Support) for gtm4wp
|
4 |
+
*
|
5 |
+
* This intergration added AMP support when using amp-wp, the existing dataLayer used
|
6 |
+
* for Google Tag Manager on HTML is loaded and built into AMP compatible code.
|
7 |
+
*
|
8 |
+
* @author Vincent Koc <https://github.com/koconder/>
|
9 |
+
* @package gtm4wp
|
10 |
+
*/
|
11 |
|
12 |
/**
|
13 |
+
*
|
14 |
+
* Todo's
|
15 |
+
*
|
16 |
+
* - Better handling of gtm4wp_amp_gtmampcode_check() to allow for other plugins
|
17 |
+
* - Develop array's into strings as AMP GTM dose not allow custom js variables
|
18 |
+
* - Better Client ID support (https://github.com/Automattic/amp-wp/issues/775)
|
19 |
+
* - Update AMP cache on GTM changes (https://github.com/Automattic/amp-wp/pull/605)
|
20 |
+
* - Supporting PWA with SuperPWA intergration with AMP and PWA for offline
|
21 |
+
*/
|
|
|
22 |
|
23 |
|
24 |
/**
|
27 |
* @author Vincent Koc <https://github.com/koconder/>
|
28 |
* @return bool Returns true if we are running on an AMP page
|
29 |
*/
|
30 |
+
function gtm4wp_amp_running() {
|
31 |
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
|
32 |
return true;
|
33 |
}
|
45 |
function gtm4wp_amp_gtmampcode_check( $data ) {
|
46 |
global $gtm4wp_amp_headerinjected;
|
47 |
|
48 |
+
//run once
|
49 |
+
if($gtm4wp_amp_headerinjected){
|
50 |
+
return $data;
|
51 |
+
}
|
52 |
+
|
53 |
// AMP-WP Plugin
|
54 |
if ( ! empty( $data['amp_analytics'] ) ) {
|
55 |
// Inject into AMP Plugin to load
|
56 |
+
$data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js';
|
57 |
+
$gtm4wp_amp_headerinjected = true;
|
58 |
|
59 |
+
// Manually load into AMP-WP Plugin
|
60 |
} else {
|
61 |
// Inject manually based on AMP <head> hook
|
62 |
add_action( 'amp_post_template_head', 'gtm4wp_amp_gtmampcode_injecthead' );
|
86 |
* @return int Returns number of injected snippets, false if no injection
|
87 |
*/
|
88 |
function gtm4wp_amp_gtmcode() {
|
89 |
+
global $gtm4wp_datalayer_json, $gtm4wp_options, $gtm4wp_amp_bodyinjected;
|
90 |
+
|
91 |
+
//run once
|
92 |
+
if($gtm4wp_amp_bodyinjected){
|
93 |
+
return false;
|
94 |
+
}
|
95 |
|
96 |
+
$gtm4wp_amp_bodyinjected = true;
|
97 |
// Check dataLayer is loaded from the plugin
|
98 |
+
if ( ! empty( $gtm4wp_datalayer_json ) ) {
|
99 |
|
100 |
// Builds a list of GTM id's
|
101 |
+
$gtm4wp_ampids = explode( ',', $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_AMPID ] );
|
102 |
$gtm4wp_ampid_list = array();
|
103 |
|
104 |
// Counter used for status return
|
108 |
if ( count( $gtm4wp_ampids ) > 0 ) {
|
109 |
|
110 |
// Loop through each GTM idea and build the AMP GTM code
|
111 |
+
foreach ( $gtm4wp_ampids as $gtm4wp_oneampid ) {
|
112 |
|
113 |
// Docs: https://developers.google.com/analytics/devguides/collection/amp-analytics/
|
114 |
// Examples: from https://www.simoahava.com/analytics/accelerated-mobile-pages-via-google-tag-manager/
|
|
|
115 |
// Inject the AMP GTM code
|
116 |
// TODO: Use AMP classes to enable cross-compatibility with other future plugins
|
117 |
+
echo '<!-- Google Tag Manager --><amp-analytics config="https://www.googletagmanager.com/amp.json?id=' . $gtm4wp_oneampid . '>m.url=SOURCE_URL" data-credentials="include">' . gtm4wp_amp_gtmvariables() . '</amp-analytics>';
|
118 |
|
119 |
// Add to counter
|
120 |
$x++;
|
121 |
}
|
122 |
|
123 |
// Check how many injections for return
|
124 |
+
if ( $x > 0 ) {
|
125 |
return $x;
|
126 |
}
|
127 |
}
|
139 |
*/
|
140 |
function gtm4wp_amp_gtmvariables() {
|
141 |
global $gtm4wp_datalayer_json;
|
142 |
+
return '{"vars":{' . $gtm4wp_datalayer_json . '} }';
|
143 |
}
|
144 |
|
145 |
|
146 |
// Set Status at start
|
147 |
$gtm4wp_amp_headerinjected = false;
|
148 |
+
$gtm4wp_amp_bodyinjected = false;
|
149 |
|
150 |
// Load AMP-Analytics tag into <head>
|
151 |
add_action( 'amp_post_template_data', 'gtm4wp_amp_gtmampcode_check' );
|
152 |
|
153 |
// Load the GTM code processing to gain the GTM DataLayer
|
154 |
+
add_action( 'amp_post_template_head', 'gtm4wp_wp_header_begin' );
|
155 |
add_action( 'amp_post_template_head', 'gtm4wp_wp_header_top', 1 );
|
156 |
|
157 |
+
// Try amp_wp_body_open
|
158 |
+
// (https://github.com/Automattic/amp-wp/pull/1143)
|
159 |
+
add_action( 'amp_post_template_body_open', 'gtm4wp_amp_gtmcode');
|
|
|
160 |
// Publish the GTM code and dataLayer to the footer
|
161 |
+
add_action( 'amp_post_template_footer', 'gtm4wp_amp_gtmcode' );
|
integration/google-optimize.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
function gtm4wp_go_pagehiding_snippet() {
|
3 |
global $gtm4wp_options;
|
4 |
|
5 |
-
$gtm4wp_goids
|
6 |
$gtm4wp_goid_pagehiding_list = array();
|
7 |
if ( count( $gtm4wp_goids ) > 0 ) {
|
8 |
-
foreach( $gtm4wp_goids as $gtm4wp_onegoid ) {
|
9 |
$gtm4wp_goid_pagehiding_list[] = "'" . $gtm4wp_onegoid . "': true";
|
10 |
}
|
11 |
|
@@ -21,23 +21,23 @@ function gtm4wp_go_pagehiding_snippet() {
|
|
21 |
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
|
22 |
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
|
23 |
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;})
|
24 |
-
(window,document.documentElement,'google-optimize-hide','dataLayer'," . $gtm4wp_gotimeout .
|
25 |
</script>
|
26 |
-
<!-- GTM4WP: End of Google Optimize Page Hiding snippet -->
|
27 |
}
|
28 |
}
|
29 |
|
30 |
function gtm4wp_go_snippet( $content ) {
|
31 |
global $gtm4wp_options;
|
32 |
|
33 |
-
if (
|
34 |
return $content;
|
35 |
}
|
36 |
|
37 |
-
$gtm4wp_goids
|
38 |
$gtm4wp_goid_list = array();
|
39 |
if ( count( $gtm4wp_goids ) > 0 ) {
|
40 |
-
foreach( $gtm4wp_goids as $gtm4wp_onegoid ) {
|
41 |
$gtm4wp_goid_list[] = "ga('require', '" . $gtm4wp_onegoid . "');";
|
42 |
}
|
43 |
|
@@ -49,13 +49,13 @@ function gtm4wp_go_snippet( $content ) {
|
|
49 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
50 |
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
51 |
ga('create', '" . $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ] . "', 'auto');
|
52 |
-
" . implode( "\n", $gtm4wp_goid_list ) .
|
53 |
</script>
|
54 |
-
<!-- GTM4WP: End of Load Google Optimize containers -->
|
55 |
}
|
56 |
|
57 |
return $content;
|
58 |
}
|
59 |
|
60 |
-
add_action(
|
61 |
-
add_filter( GTM4WP_WPFILTER_AFTER_DATALAYER,
|
2 |
function gtm4wp_go_pagehiding_snippet() {
|
3 |
global $gtm4wp_options;
|
4 |
|
5 |
+
$gtm4wp_goids = explode( ',', $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] );
|
6 |
$gtm4wp_goid_pagehiding_list = array();
|
7 |
if ( count( $gtm4wp_goids ) > 0 ) {
|
8 |
+
foreach ( $gtm4wp_goids as $gtm4wp_onegoid ) {
|
9 |
$gtm4wp_goid_pagehiding_list[] = "'" . $gtm4wp_onegoid . "': true";
|
10 |
}
|
11 |
|
21 |
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
|
22 |
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
|
23 |
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;})
|
24 |
+
(window,document.documentElement,'google-optimize-hide','dataLayer'," . $gtm4wp_gotimeout . ',{' . implode( ', ', $gtm4wp_goid_pagehiding_list ) . '});
|
25 |
</script>
|
26 |
+
<!-- GTM4WP: End of Google Optimize Page Hiding snippet -->';
|
27 |
}
|
28 |
}
|
29 |
|
30 |
function gtm4wp_go_snippet( $content ) {
|
31 |
global $gtm4wp_options;
|
32 |
|
33 |
+
if ( '' == $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ] ) {
|
34 |
return $content;
|
35 |
}
|
36 |
|
37 |
+
$gtm4wp_goids = explode( ',', $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] );
|
38 |
$gtm4wp_goid_list = array();
|
39 |
if ( count( $gtm4wp_goids ) > 0 ) {
|
40 |
+
foreach ( $gtm4wp_goids as $gtm4wp_onegoid ) {
|
41 |
$gtm4wp_goid_list[] = "ga('require', '" . $gtm4wp_onegoid . "');";
|
42 |
}
|
43 |
|
49 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
50 |
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
51 |
ga('create', '" . $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ] . "', 'auto');
|
52 |
+
" . implode( "\n", $gtm4wp_goid_list ) . '
|
53 |
</script>
|
54 |
+
<!-- GTM4WP: End of Load Google Optimize containers -->';
|
55 |
}
|
56 |
|
57 |
return $content;
|
58 |
}
|
59 |
|
60 |
+
add_action( 'wp_head', 'gtm4wp_go_pagehiding_snippet', 1 );
|
61 |
+
add_filter( GTM4WP_WPFILTER_AFTER_DATALAYER, 'gtm4wp_go_snippet' );
|
integration/soundcloud.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
if ( ! is_admin() ) {
|
3 |
-
$in_footer = apply_filters( 'gtm4wp_soundcloud', false);
|
4 |
-
wp_enqueue_script(
|
5 |
-
wp_enqueue_script(
|
6 |
-
}
|
1 |
<?php
|
2 |
if ( ! is_admin() ) {
|
3 |
+
$in_footer = apply_filters( 'gtm4wp_soundcloud', false );
|
4 |
+
wp_enqueue_script( 'gtm4wp-soundcloud-api', 'https://w.soundcloud.com/player/api.js', array(), '1.0', $in_footer );
|
5 |
+
wp_enqueue_script( 'gtm4wp-soundcloud', $gtp4wp_plugin_url . 'js/gtm4wp-soundcloud.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
6 |
+
}
|
integration/vimeo.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
if ( ! is_admin() ) {
|
3 |
-
$in_footer = apply_filters( 'gtm4wp_vimeo', false);
|
4 |
-
//
|
5 |
-
wp_enqueue_script(
|
6 |
-
wp_enqueue_script(
|
7 |
-
}
|
1 |
<?php
|
2 |
if ( ! is_admin() ) {
|
3 |
+
$in_footer = apply_filters( 'gtm4wp_vimeo', false );
|
4 |
+
// wp_enqueue_script( "gtm4wp-vimeo-froogaloop", $gtp4wp_plugin_url . "js/froogaloop.js", array(), "2.0", $in_footer );
|
5 |
+
wp_enqueue_script( 'gtm4wp-vimeo-api', 'https://player.vimeo.com/api/player.js', array(), '1.0', $in_footer );
|
6 |
+
wp_enqueue_script( 'gtm4wp-vimeo', $gtp4wp_plugin_url . 'js/gtm4wp-vimeo.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
7 |
+
}
|
integration/woocommerce.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
define( 'GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY', 'gtm4wp_eec_product_array' );
|
3 |
-
define( 'GTM4WP_WPFILTER_EEC_CART_ITEM',
|
4 |
-
define( 'GTM4WP_WPFILTER_EEC_ORDER_ITEM',
|
5 |
|
6 |
$gtm4wp_product_counter = 0;
|
7 |
-
$gtm4wp_last_widget_title =
|
8 |
-
if ( function_exists
|
9 |
-
$GLOBALS[
|
10 |
} else {
|
11 |
-
$GLOBALS[
|
12 |
}
|
13 |
|
14 |
function gtm4wp_woocommerce_addjs( $js ) {
|
15 |
$woo = WC();
|
16 |
|
17 |
-
if ( version_compare( $woo->version,
|
18 |
wc_enqueue_js( $js );
|
19 |
} else {
|
20 |
$woo->add_inline_js( $js );
|
@@ -22,35 +22,35 @@ function gtm4wp_woocommerce_addjs( $js ) {
|
|
22 |
}
|
23 |
|
24 |
// from https://snippets.webaware.com.au/ramblings/php-really-doesnt-unicode/
|
25 |
-
function gtm4wp_untexturize($fancy) {
|
26 |
$fixes = false;
|
27 |
|
28 |
if ( $fixes === false ) {
|
29 |
$fixes = array(
|
30 |
-
json_decode('"\u201C"') => '"',
|
31 |
-
json_decode('"\u201D"') => '"',
|
32 |
-
json_decode('"\u2018"') => "'",
|
33 |
-
json_decode('"\u2019"') => "'",
|
34 |
-
json_decode('"\u2032"') => "'",
|
35 |
-
json_decode('"\u2033"') => '"',
|
36 |
-
json_decode('"\u2013"') => '-',
|
37 |
-
json_decode('"\u2014"') => '--',
|
38 |
);
|
39 |
}
|
40 |
|
41 |
-
$normal = strtr($fancy, $fixes);
|
42 |
|
43 |
return $normal;
|
44 |
}
|
45 |
|
46 |
function gtm4wp_woocommerce_html_entity_decode( $val ) {
|
47 |
-
return gtm4wp_untexturize( html_entity_decode( $val, ENT_QUOTES,
|
48 |
}
|
49 |
|
50 |
function gtm4wp_prefix_productid( $product_id ) {
|
51 |
global $gtm4wp_options;
|
52 |
|
53 |
-
if (
|
54 |
return $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ] . $product_id;
|
55 |
} else {
|
56 |
return $product_id;
|
@@ -58,21 +58,25 @@ function gtm4wp_prefix_productid( $product_id ) {
|
|
58 |
}
|
59 |
|
60 |
// from https://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match
|
61 |
-
function gtm4wp_str_replace_first($from, $to, $subject) {
|
62 |
-
$from = '/'.preg_quote($from, '/').'/';
|
63 |
|
64 |
-
return preg_replace($from, $to, $subject, 1);
|
65 |
}
|
66 |
|
67 |
function gtm4wp_get_product_category_hierarchy( $category_id ) {
|
68 |
-
$cat_hierarchy =
|
69 |
-
|
70 |
-
$category_parent_list = get_term_parents_list(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
|
77 |
if ( is_string( $category_parent_list ) ) {
|
78 |
$cat_hierarchy = trim( $category_parent_list, '/' );
|
@@ -81,11 +85,11 @@ function gtm4wp_get_product_category_hierarchy( $category_id ) {
|
|
81 |
return $cat_hierarchy;
|
82 |
}
|
83 |
|
84 |
-
function gtm4wp_get_product_category( $product_id, $fullpath = false) {
|
85 |
-
|
86 |
|
87 |
$_product_cats = get_the_terms( $product_id, 'product_cat' );
|
88 |
-
if ( ( is_array($_product_cats) ) && ( count( $_product_cats ) > 0 ) ) {
|
89 |
$first_product_cat = array_pop( $_product_cats );
|
90 |
if ( $fullpath ) {
|
91 |
$product_cat = gtm4wp_get_product_category_hierarchy( $first_product_cat->term_id );
|
@@ -97,17 +101,26 @@ function gtm4wp_get_product_category( $product_id, $fullpath = false) {
|
|
97 |
return $product_cat;
|
98 |
}
|
99 |
|
100 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
global $gtm4wp_options;
|
102 |
|
103 |
-
$return .=
|
104 |
-
var gtm4wp_use_sku_instead =
|
105 |
-
var gtm4wp_id_prefix = '" . esc_js( gtm4wp_prefix_productid(
|
106 |
-
var gtm4wp_remarketing = " . gtm4wp_escjs_boolean((
|
107 |
-
var gtm4wp_eec =
|
108 |
-
var gtm4wp_classicec =
|
109 |
var gtm4wp_currency = '" . esc_js( get_woocommerce_currency() ) . "';
|
110 |
-
var gtm4wp_product_per_impression = " . (int)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ]) .
|
111 |
|
112 |
return $return;
|
113 |
}
|
@@ -121,47 +134,103 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
121 |
// we need to use this instead of $woo->customer as this will load proper total order number and value from the database instead of the session
|
122 |
$woo_customer = new WC_Customer( $woo->customer->get_id() );
|
123 |
|
124 |
-
$dataLayer[
|
125 |
-
$dataLayer[
|
126 |
-
|
127 |
-
$dataLayer[
|
128 |
-
$dataLayer[
|
129 |
-
|
130 |
-
$dataLayer[
|
131 |
-
$dataLayer[
|
132 |
-
$dataLayer[
|
133 |
-
$dataLayer[
|
134 |
-
$dataLayer[
|
135 |
-
$dataLayer[
|
136 |
-
$dataLayer[
|
137 |
-
$dataLayer[
|
138 |
-
$dataLayer[
|
139 |
-
$dataLayer[
|
140 |
-
|
141 |
-
$dataLayer[
|
142 |
-
$dataLayer[
|
143 |
-
$dataLayer[
|
144 |
-
$dataLayer[
|
145 |
-
$dataLayer[
|
146 |
-
$dataLayer[
|
147 |
-
$dataLayer[
|
148 |
-
$dataLayer[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
if ( is_product_category() || is_product_tag() || is_front_page() || is_shop() ) {
|
152 |
-
$ecomm_pagetype =
|
153 |
if ( is_front_page() ) {
|
154 |
-
$ecomm_pagetype =
|
155 |
-
}
|
156 |
-
$ecomm_pagetype =
|
157 |
}
|
158 |
|
159 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
160 |
-
$dataLayer[
|
161 |
-
$dataLayer[
|
162 |
-
$dataLayer[
|
163 |
}
|
164 |
-
}
|
165 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) {
|
166 |
$postid = get_the_ID();
|
167 |
$product = wc_get_product( $postid );
|
@@ -171,54 +240,61 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
171 |
|
172 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) {
|
173 |
$product_sku = $product->get_sku();
|
174 |
-
if (
|
175 |
$product_id = $product_sku;
|
176 |
}
|
177 |
}
|
178 |
-
$remarketing_id = (string)$product_id;
|
179 |
-
$product_price
|
|
|
|
|
|
|
|
|
180 |
|
181 |
-
if (
|
182 |
-
$dataLayer[
|
183 |
|
184 |
$_temp_productdata = array(
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
);
|
191 |
-
$
|
|
|
|
|
|
|
192 |
|
193 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
194 |
-
$dataLayer[
|
195 |
-
$dataLayer[
|
196 |
-
$dataLayer[
|
197 |
}
|
198 |
|
199 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
200 |
-
$dataLayer[
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
)
|
205 |
);
|
206 |
}
|
207 |
} else {
|
208 |
-
$dataLayer[
|
209 |
|
210 |
-
$dataLayer[
|
211 |
-
$dataLayer[
|
212 |
-
$dataLayer[
|
213 |
}
|
214 |
}
|
215 |
-
}
|
216 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] || $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
217 |
$gtm4wp_cart_products = array();
|
218 |
$gtm4wp_cart_products_remarketing = array();
|
219 |
|
220 |
-
foreach( $woo->cart->get_cart() as $cart_item_id => $cart_item_data) {
|
221 |
-
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data[
|
222 |
|
223 |
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
224 |
continue;
|
@@ -227,34 +303,38 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
227 |
$product_id = $product->get_id();
|
228 |
$product_type = $product->get_type();
|
229 |
|
230 |
-
if (
|
231 |
-
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
232 |
-
$product_cat
|
233 |
} else {
|
234 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
235 |
}
|
236 |
|
237 |
$remarketing_id = $product_id;
|
238 |
$product_sku = $product->get_sku();
|
239 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
240 |
$remarketing_id = $product_sku;
|
241 |
}
|
242 |
|
243 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
244 |
$_temp_productdata = array(
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
);
|
252 |
|
253 |
-
if ( "
|
254 |
-
$_temp_productdata[ "
|
255 |
}
|
256 |
|
257 |
-
|
|
|
|
|
|
|
|
|
258 |
$gtm4wp_cart_products[] = $eec_product_array;
|
259 |
}
|
260 |
|
@@ -262,37 +342,37 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
262 |
}
|
263 |
|
264 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
265 |
-
$dataLayer[
|
266 |
-
$dataLayer[
|
267 |
if ( ! $woo->cart->prices_include_tax ) {
|
268 |
$cart_total = $woo->cart->cart_contents_total;
|
269 |
} else {
|
270 |
$cart_total = $woo->cart->cart_contents_total + $woo->cart->tax_total;
|
271 |
}
|
272 |
-
$dataLayer[
|
273 |
}
|
274 |
|
275 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
276 |
-
$dataLayer[
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
),
|
282 |
-
|
283 |
-
)
|
284 |
);
|
285 |
}
|
286 |
}
|
287 |
-
}
|
288 |
-
$do_not_flag_tracked_order = (
|
289 |
-
$order_id = empty( $_GET[
|
290 |
$order_id_filtered = apply_filters( 'woocommerce_thankyou_order_id', $order_id );
|
291 |
-
if (
|
292 |
$order_id = $order_id_filtered;
|
293 |
}
|
294 |
|
295 |
-
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET[
|
296 |
|
297 |
if ( $order_id > 0 ) {
|
298 |
$order = wc_get_order( $order_id );
|
@@ -312,53 +392,63 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
312 |
}
|
313 |
}
|
314 |
|
315 |
-
if ( ( 1 == get_post_meta( $order_id, '_ga_tracked', true ) ) &&
|
|
|
|
|
|
|
|
|
316 |
unset( $order );
|
317 |
}
|
318 |
|
319 |
if ( isset( $order ) ) {
|
320 |
-
|
321 |
-
|
322 |
} else {
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
}
|
325 |
|
326 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
327 |
-
$dataLayer[
|
328 |
-
$dataLayer[
|
329 |
-
$dataLayer[
|
330 |
-
$dataLayer[
|
331 |
-
$dataLayer[
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
$dataLayer[
|
338 |
-
$dataLayer["transactionPaymentType"] = ( $gtm4wp_is_woocommerce3 ? $order->get_payment_method_title() : $order->payment_method_title);
|
339 |
-
$dataLayer["transactionCurrency"] = get_woocommerce_currency();
|
340 |
-
$dataLayer["transactionShippingMethod"] = $order->get_shipping_method();
|
341 |
-
$dataLayer["transactionPromoCode"] = implode( ", ", $order->get_used_coupons() );
|
342 |
}
|
343 |
|
344 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
345 |
-
$dataLayer[
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
)
|
356 |
-
)
|
357 |
);
|
358 |
}
|
359 |
|
360 |
-
$_products
|
361 |
-
$_sumprice
|
362 |
$_product_ids = array();
|
363 |
|
364 |
if ( $order->get_items() ) {
|
@@ -368,184 +458,197 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
368 |
continue;
|
369 |
}
|
370 |
|
371 |
-
$product = ( $gtm4wp_is_woocommerce3 ? $item->get_product() : $order->get_product_from_item( $item ) )
|
372 |
|
373 |
$product_id = $product->get_id();
|
374 |
$product_type = $product->get_type();
|
375 |
|
376 |
-
if (
|
377 |
-
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
378 |
-
$product_cat
|
379 |
} else {
|
380 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
381 |
}
|
382 |
|
383 |
$remarketing_id = $product_id;
|
384 |
$product_sku = $product->get_sku();
|
385 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
386 |
$remarketing_id = $product_sku;
|
387 |
}
|
388 |
|
389 |
-
$product_price
|
390 |
$_temp_productdata = array(
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
);
|
400 |
|
401 |
-
if ( "
|
402 |
-
$_temp_productdata[ "
|
403 |
}
|
404 |
|
405 |
-
|
406 |
-
|
|
|
|
|
|
|
|
|
407 |
|
408 |
-
$_sumprice
|
409 |
$_product_ids[] = gtm4wp_prefix_productid( $remarketing_id );
|
410 |
}
|
411 |
}
|
412 |
|
413 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
414 |
-
$dataLayer[
|
415 |
-
$dataLayer[
|
416 |
}
|
417 |
|
418 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
419 |
-
$dataLayer[
|
420 |
-
$dataLayer[
|
421 |
}
|
422 |
|
423 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
424 |
-
$dataLayer[
|
425 |
-
$dataLayer[
|
426 |
-
$dataLayer[
|
427 |
}
|
428 |
|
429 |
-
if (
|
430 |
update_post_meta( $order_id, '_ga_tracked', 1 );
|
431 |
}
|
432 |
}
|
433 |
-
}
|
434 |
if ( ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) ) {
|
435 |
$gtm4wp_checkout_products = array();
|
436 |
$gtm4wp_checkout_products_remarketing = array();
|
437 |
$gtm4wp_totalvalue = 0;
|
438 |
|
439 |
-
foreach( $woo->cart->get_cart() as $cart_item_id => $cart_item_data) {
|
440 |
-
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data[
|
441 |
|
442 |
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
443 |
continue;
|
444 |
}
|
445 |
|
446 |
-
$product_id
|
447 |
$product_type = $product->get_type();
|
448 |
|
449 |
-
if (
|
450 |
-
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
451 |
-
$product_cat
|
452 |
} else {
|
453 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
454 |
}
|
455 |
|
456 |
$remarketing_id = $product_id;
|
457 |
$product_sku = $product->get_sku();
|
458 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
459 |
$remarketing_id = $product_sku;
|
460 |
}
|
461 |
|
462 |
$_temp_productdata = array(
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
);
|
470 |
|
471 |
-
if ( "
|
472 |
-
$_temp_productdata[ "
|
473 |
}
|
474 |
|
475 |
-
|
|
|
|
|
|
|
|
|
476 |
$gtm4wp_checkout_products[] = $eec_product_array;
|
477 |
|
478 |
$gtm4wp_checkout_products_remarketing[] = gtm4wp_prefix_productid( $remarketing_id );
|
479 |
-
$gtm4wp_totalvalue
|
480 |
} // end foreach cart item
|
481 |
|
482 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
483 |
-
$dataLayer[
|
484 |
-
$dataLayer[
|
485 |
-
$dataLayer[
|
486 |
}
|
487 |
|
488 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
489 |
-
$dataLayer[
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
),
|
495 |
-
|
496 |
-
)
|
497 |
);
|
498 |
|
499 |
-
gtm4wp_woocommerce_addjs(
|
500 |
-
|
501 |
-
window.
|
|
|
502 |
);
|
503 |
}
|
504 |
}
|
505 |
} else {
|
506 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
507 |
-
$dataLayer[
|
508 |
}
|
509 |
}
|
510 |
|
511 |
-
if ( isset
|
512 |
-
$cart_item
|
513 |
-
if ( !empty( $cart_item ) ) {
|
514 |
-
$product
|
515 |
|
516 |
$product_id = $product->get_id();
|
517 |
$product_type = $product->get_type();
|
518 |
|
519 |
-
if (
|
520 |
-
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
521 |
-
$product_cat
|
522 |
} else {
|
523 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
524 |
}
|
525 |
|
526 |
$remarketing_id = $product_id;
|
527 |
$product_sku = $product->get_sku();
|
528 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
529 |
$remarketing_id = $product_sku;
|
530 |
}
|
531 |
|
532 |
-
$dataLayer[
|
533 |
-
$dataLayer[
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
);
|
541 |
|
542 |
-
if ( "
|
543 |
-
$dataLayer["ecommerce"]["add"][0][ "
|
|
|
|
|
|
|
|
|
544 |
}
|
545 |
}
|
546 |
|
547 |
gtm4wp_woocommerce_addjs( "document.cookie = 'gtm4wp_product_readded_to_cart=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';" );
|
548 |
-
unset( $_COOKIE[
|
549 |
}
|
550 |
|
551 |
return $dataLayer;
|
@@ -565,85 +668,96 @@ function gtm4wp_woocommerce_single_add_to_cart_tracking() {
|
|
565 |
|
566 |
$remarketing_id = $product_id;
|
567 |
$product_sku = $product->get_sku();
|
568 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
569 |
$remarketing_id = $product_sku;
|
570 |
}
|
571 |
|
572 |
$_temp_productdata = array(
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
);
|
581 |
-
$
|
|
|
|
|
|
|
582 |
|
583 |
-
foreach( $eec_product_array as $eec_product_array_key => $eec_product_array_value ) {
|
584 |
-
echo '<input type="hidden" name="gtm4wp_' . esc_attr( $eec_product_array_key ). '" value="' . esc_attr( $eec_product_array_value ). '" />'."\n";
|
585 |
}
|
586 |
}
|
587 |
|
588 |
-
$GLOBALS[
|
589 |
-
function gtm4wp_woocommerce_cart_item_product_filter( $product, $cart_item=
|
590 |
global $gtm4wp_options, $gtm4wp_is_woocommerce3;
|
591 |
|
592 |
$product_id = $product->get_id();
|
593 |
$product_type = $product->get_type();
|
594 |
|
595 |
-
if (
|
596 |
-
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
597 |
-
$product_cat
|
598 |
} else {
|
599 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
600 |
}
|
601 |
|
602 |
$remarketing_id = $product_id;
|
603 |
$product_sku = $product->get_sku();
|
604 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
605 |
$remarketing_id = $product_sku;
|
606 |
}
|
607 |
|
608 |
$_temp_productdata = array(
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
);
|
617 |
|
618 |
-
if ( "
|
619 |
-
$_temp_productdata[ "
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
}
|
621 |
|
622 |
-
$eec_product_array
|
623 |
-
$GLOBALS[
|
624 |
|
625 |
return $product;
|
626 |
}
|
627 |
|
628 |
function gtm4wp_woocommerce_cart_item_remove_link_filter( $remove_from_cart_link ) {
|
629 |
-
if ( ! isset( $GLOBALS[
|
630 |
return $remove_from_cart_link;
|
631 |
}
|
632 |
|
633 |
-
if ( ! is_array( $GLOBALS[
|
634 |
return $remove_from_cart_link;
|
635 |
}
|
636 |
|
637 |
-
$cartlink_with_data
|
638 |
-
|
639 |
-
esc_attr( $GLOBALS[
|
640 |
-
esc_attr( $GLOBALS[
|
641 |
-
esc_attr( $GLOBALS[
|
642 |
-
|
643 |
-
|
644 |
-
esc_attr( $GLOBALS[
|
|
|
|
|
645 |
);
|
646 |
-
$GLOBALS[
|
647 |
|
648 |
return gtm4wp_str_replace_first( 'href="', $cartlink_with_data, $remove_from_cart_link );
|
649 |
}
|
@@ -651,13 +765,13 @@ function gtm4wp_woocommerce_cart_item_remove_link_filter( $remove_from_cart_link
|
|
651 |
function gtp4wp_woocommerce_reset_loop() {
|
652 |
global $woocommerce_loop;
|
653 |
|
654 |
-
$woocommerce_loop[
|
655 |
}
|
656 |
|
657 |
function gtm4wp_woocommerce_add_related_to_loop( $arg ) {
|
658 |
global $woocommerce_loop;
|
659 |
|
660 |
-
$woocommerce_loop[
|
661 |
|
662 |
return $arg;
|
663 |
}
|
@@ -665,7 +779,7 @@ function gtm4wp_woocommerce_add_related_to_loop( $arg ) {
|
|
665 |
function gtm4wp_woocommerce_add_cross_sell_to_loop( $arg ) {
|
666 |
global $woocommerce_loop;
|
667 |
|
668 |
-
$woocommerce_loop[
|
669 |
|
670 |
return $arg;
|
671 |
}
|
@@ -673,7 +787,7 @@ function gtm4wp_woocommerce_add_cross_sell_to_loop( $arg ) {
|
|
673 |
function gtm4wp_woocommerce_add_upsells_to_loop( $arg ) {
|
674 |
global $woocommerce_loop;
|
675 |
|
676 |
-
$woocommerce_loop[
|
677 |
|
678 |
return $arg;
|
679 |
}
|
@@ -688,37 +802,44 @@ function gtm4wp_woocommerce_after_template_part( $template_name ) {
|
|
688 |
$productitem = ob_get_contents();
|
689 |
ob_end_clean();
|
690 |
|
691 |
-
if (
|
692 |
-
|
693 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
694 |
|
695 |
$remarketing_id = $product_id;
|
696 |
$product_sku = $product->get_sku();
|
697 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
698 |
$remarketing_id = $product_sku;
|
699 |
}
|
700 |
|
701 |
$_temp_productdata = array(
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
);
|
711 |
-
$
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
esc_attr( $eec_product_array[
|
721 |
-
esc_attr( $eec_product_array[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
722 |
);
|
723 |
|
724 |
$gtm4wp_product_counter++;
|
@@ -732,8 +853,8 @@ function gtm4wp_woocommerce_after_template_part( $template_name ) {
|
|
732 |
function gtm4wp_widget_title_filter( $widget_title ) {
|
733 |
global $gtm4wp_product_counter, $gtm4wp_last_widget_title;
|
734 |
|
735 |
-
$gtm4wp_product_counter
|
736 |
-
$gtm4wp_last_widget_title = $widget_title . __(
|
737 |
|
738 |
return $widget_title;
|
739 |
}
|
@@ -741,49 +862,49 @@ function gtm4wp_widget_title_filter( $widget_title ) {
|
|
741 |
function gtm4wp_before_recent_products_loop() {
|
742 |
global $woocommerce_loop;
|
743 |
|
744 |
-
$woocommerce_loop[
|
745 |
}
|
746 |
|
747 |
function gtm4wp_before_sale_products_loop() {
|
748 |
global $woocommerce_loop;
|
749 |
|
750 |
-
$woocommerce_loop[
|
751 |
}
|
752 |
|
753 |
function gtm4wp_before_best_selling_products_loop() {
|
754 |
global $woocommerce_loop;
|
755 |
|
756 |
-
$woocommerce_loop[
|
757 |
}
|
758 |
|
759 |
function gtm4wp_before_top_rated_products_loop() {
|
760 |
global $woocommerce_loop;
|
761 |
|
762 |
-
$woocommerce_loop[
|
763 |
}
|
764 |
|
765 |
function gtm4wp_before_featured_products_loop() {
|
766 |
global $woocommerce_loop;
|
767 |
|
768 |
-
$woocommerce_loop[
|
769 |
}
|
770 |
|
771 |
function gtm4wp_before_related_products_loop() {
|
772 |
global $woocommerce_loop;
|
773 |
|
774 |
-
$woocommerce_loop[
|
775 |
}
|
776 |
|
777 |
function gtm4wp_woocommerce_before_shop_loop_item() {
|
778 |
global $product, $woocommerce_loop, $wp_query, $gtm4wp_options;
|
779 |
|
780 |
-
if ( !isset( $product ) ) {
|
781 |
return;
|
782 |
}
|
783 |
|
784 |
-
$product_id
|
785 |
|
786 |
-
$product_cat =
|
787 |
if ( is_product_category() ) {
|
788 |
global $wp_query;
|
789 |
$cat_obj = $wp_query->get_queried_object();
|
@@ -797,64 +918,71 @@ function gtm4wp_woocommerce_before_shop_loop_item() {
|
|
797 |
}
|
798 |
|
799 |
if ( is_search() ) {
|
800 |
-
$list_name = __(
|
801 |
-
}
|
802 |
-
$list_name = $woocommerce_loop[
|
803 |
} else {
|
804 |
-
$list_name = __(
|
805 |
}
|
806 |
|
807 |
-
$paged
|
808 |
-
$posts_per_page = get_query_var('posts_per_page');
|
809 |
if ( $posts_per_page < 1 ) {
|
810 |
$posts_per_page = 1;
|
811 |
}
|
812 |
|
813 |
$remarketing_id = $product_id;
|
814 |
$product_sku = $product->get_sku();
|
815 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && (
|
816 |
$remarketing_id = $product_sku;
|
817 |
}
|
818 |
|
819 |
$_temp_productdata = array(
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
);
|
829 |
-
$
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
esc_attr( $eec_product_array[
|
839 |
-
esc_attr( $eec_product_array[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
840 |
);
|
841 |
}
|
842 |
|
843 |
function gtm4wp_woocommerce_cart_item_restored( $cart_item_key ) {
|
844 |
-
setcookie(
|
845 |
}
|
846 |
|
847 |
function gtm4wp_woocommerce_enqueue_scripts() {
|
848 |
-
|
849 |
|
850 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
851 |
-
|
852 |
-
wp_enqueue_script(
|
853 |
}
|
854 |
|
855 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
856 |
-
|
857 |
-
wp_enqueue_script(
|
858 |
}
|
859 |
}
|
860 |
|
@@ -862,7 +990,7 @@ function gtm4wp_wc_quick_view_before_single_product() {
|
|
862 |
global $gtm4wp_options, $gtm4wp_datalayer_name;
|
863 |
|
864 |
$dataLayer = array(
|
865 |
-
|
866 |
);
|
867 |
|
868 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) {
|
@@ -874,83 +1002,88 @@ function gtm4wp_wc_quick_view_before_single_product() {
|
|
874 |
|
875 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) {
|
876 |
$product_sku = $product->get_sku();
|
877 |
-
if (
|
878 |
$product_id = $product_sku;
|
879 |
}
|
880 |
}
|
881 |
-
$remarketing_id = (string)$product_id;
|
882 |
-
$product_price
|
883 |
|
884 |
-
if (
|
885 |
$_temp_productdata = array(
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
);
|
892 |
-
$
|
|
|
|
|
|
|
|
|
|
|
893 |
|
894 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
895 |
-
$dataLayer[
|
896 |
-
$dataLayer[
|
897 |
-
$dataLayer[
|
898 |
}
|
899 |
|
900 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
901 |
-
$dataLayer[
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
)
|
906 |
);
|
907 |
}
|
908 |
} else {
|
909 |
-
$dataLayer[
|
910 |
-
$dataLayer[
|
911 |
-
$dataLayer[
|
912 |
}
|
913 |
}
|
914 |
|
915 |
echo '
|
916 |
<script>
|
917 |
-
'. $gtm4wp_datalayer_name .'.push(' . json_encode( $dataLayer ). ');
|
918 |
</script>';
|
919 |
}
|
920 |
|
921 |
// do not add filter if someone enabled WooCommerce integration without an activated WooCommerce plugin
|
922 |
-
if ( function_exists
|
923 |
-
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER,
|
924 |
-
|
925 |
-
add_filter(
|
926 |
-
add_action(
|
927 |
-
add_action(
|
928 |
-
|
929 |
-
//
|
930 |
-
add_action(
|
931 |
-
add_filter( GTM4WP_WPACTION_ADDGLOBALVARS,
|
932 |
-
|
933 |
-
if ( true === $GLOBALS[
|
934 |
-
//
|
935 |
-
add_action(
|
936 |
-
add_action(
|
937 |
-
add_filter(
|
938 |
-
add_action(
|
939 |
-
|
940 |
-
add_filter(
|
941 |
-
add_filter(
|
942 |
-
add_action(
|
943 |
-
|
944 |
-
add_filter(
|
945 |
-
add_filter(
|
946 |
-
add_filter(
|
947 |
-
add_filter(
|
948 |
-
|
949 |
-
add_action(
|
950 |
-
add_action(
|
951 |
-
add_action(
|
952 |
-
add_action(
|
953 |
-
add_action(
|
954 |
-
add_action(
|
955 |
}
|
956 |
-
}
|
1 |
<?php
|
2 |
define( 'GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY', 'gtm4wp_eec_product_array' );
|
3 |
+
define( 'GTM4WP_WPFILTER_EEC_CART_ITEM', 'gtm4wp_eec_cart_item' );
|
4 |
+
define( 'GTM4WP_WPFILTER_EEC_ORDER_ITEM', 'gtm4wp_eec_order_item' );
|
5 |
|
6 |
$gtm4wp_product_counter = 0;
|
7 |
+
$gtm4wp_last_widget_title = 'Sidebar Products';
|
8 |
+
if ( function_exists( 'WC' ) ) {
|
9 |
+
$GLOBALS['gtm4wp_is_woocommerce3'] = version_compare( WC()->version, '3.0', '>=' );
|
10 |
} else {
|
11 |
+
$GLOBALS['gtm4wp_is_woocommerce3'] = false;
|
12 |
}
|
13 |
|
14 |
function gtm4wp_woocommerce_addjs( $js ) {
|
15 |
$woo = WC();
|
16 |
|
17 |
+
if ( version_compare( $woo->version, '2.1', '>=' ) ) {
|
18 |
wc_enqueue_js( $js );
|
19 |
} else {
|
20 |
$woo->add_inline_js( $js );
|
22 |
}
|
23 |
|
24 |
// from https://snippets.webaware.com.au/ramblings/php-really-doesnt-unicode/
|
25 |
+
function gtm4wp_untexturize( $fancy ) {
|
26 |
$fixes = false;
|
27 |
|
28 |
if ( $fixes === false ) {
|
29 |
$fixes = array(
|
30 |
+
json_decode( '"\u201C"' ) => '"', // left double quotation mark
|
31 |
+
json_decode( '"\u201D"' ) => '"', // right double quotation mark
|
32 |
+
json_decode( '"\u2018"' ) => "'", // left single quotation mark
|
33 |
+
json_decode( '"\u2019"' ) => "'", // right single quotation mark
|
34 |
+
json_decode( '"\u2032"' ) => "'", // prime (minutes, feet)
|
35 |
+
json_decode( '"\u2033"' ) => '"', // double prime (seconds, inches)
|
36 |
+
json_decode( '"\u2013"' ) => '-', // en dash
|
37 |
+
json_decode( '"\u2014"' ) => '--', // em dash
|
38 |
);
|
39 |
}
|
40 |
|
41 |
+
$normal = strtr( $fancy, $fixes );
|
42 |
|
43 |
return $normal;
|
44 |
}
|
45 |
|
46 |
function gtm4wp_woocommerce_html_entity_decode( $val ) {
|
47 |
+
return gtm4wp_untexturize( html_entity_decode( $val, ENT_QUOTES, 'utf-8' ) );
|
48 |
}
|
49 |
|
50 |
function gtm4wp_prefix_productid( $product_id ) {
|
51 |
global $gtm4wp_options;
|
52 |
|
53 |
+
if ( '' != $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ] ) {
|
54 |
return $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ] . $product_id;
|
55 |
} else {
|
56 |
return $product_id;
|
58 |
}
|
59 |
|
60 |
// from https://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match
|
61 |
+
function gtm4wp_str_replace_first( $from, $to, $subject ) {
|
62 |
+
$from = '/' . preg_quote( $from, '/' ) . '/';
|
63 |
|
64 |
+
return preg_replace( $from, $to, $subject, 1 );
|
65 |
}
|
66 |
|
67 |
function gtm4wp_get_product_category_hierarchy( $category_id ) {
|
68 |
+
$cat_hierarchy = '';
|
69 |
+
|
70 |
+
$category_parent_list = get_term_parents_list(
|
71 |
+
$category_id,
|
72 |
+
'product_cat',
|
73 |
+
array(
|
74 |
+
'format' => 'name',
|
75 |
+
'separator' => '/',
|
76 |
+
'link' => false,
|
77 |
+
'inclusive' => true,
|
78 |
+
)
|
79 |
+
);
|
80 |
|
81 |
if ( is_string( $category_parent_list ) ) {
|
82 |
$cat_hierarchy = trim( $category_parent_list, '/' );
|
85 |
return $cat_hierarchy;
|
86 |
}
|
87 |
|
88 |
+
function gtm4wp_get_product_category( $product_id, $fullpath = false ) {
|
89 |
+
$product_cat = '';
|
90 |
|
91 |
$_product_cats = get_the_terms( $product_id, 'product_cat' );
|
92 |
+
if ( ( is_array( $_product_cats ) ) && ( count( $_product_cats ) > 0 ) ) {
|
93 |
$first_product_cat = array_pop( $_product_cats );
|
94 |
if ( $fullpath ) {
|
95 |
$product_cat = gtm4wp_get_product_category_hierarchy( $first_product_cat->term_id );
|
101 |
return $product_cat;
|
102 |
}
|
103 |
|
104 |
+
function gtm4wp_woocommerce_getproductterm( $product_id, $taxonomy ) {
|
105 |
+
$gtm4wp_product_terms = get_the_terms( $product_id, $taxonomy );
|
106 |
+
if ( is_array( $gtm4wp_product_terms ) && ( count( $gtm4wp_product_terms ) > 0 ) ) {
|
107 |
+
return $gtm4wp_product_terms[0]->name;
|
108 |
+
}
|
109 |
+
|
110 |
+
return "";
|
111 |
+
}
|
112 |
+
|
113 |
+
function gtm4wp_woocommerce_addglobalvars( $return = '' ) {
|
114 |
global $gtm4wp_options;
|
115 |
|
116 |
+
$return .= '
|
117 |
+
var gtm4wp_use_sku_instead = ' . (int) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) . ";
|
118 |
+
var gtm4wp_id_prefix = '" . esc_js( gtm4wp_prefix_productid( '' ) ) . "';
|
119 |
+
var gtm4wp_remarketing = " . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) ) . ';
|
120 |
+
var gtm4wp_eec = ' . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) . ';
|
121 |
+
var gtm4wp_classicec = ' . gtm4wp_escjs_boolean( (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) ) . ";
|
122 |
var gtm4wp_currency = '" . esc_js( get_woocommerce_currency() ) . "';
|
123 |
+
var gtm4wp_product_per_impression = " . (int) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ] ) . ';';
|
124 |
|
125 |
return $return;
|
126 |
}
|
134 |
// we need to use this instead of $woo->customer as this will load proper total order number and value from the database instead of the session
|
135 |
$woo_customer = new WC_Customer( $woo->customer->get_id() );
|
136 |
|
137 |
+
$dataLayer['customerTotalOrders'] = $woo_customer->get_order_count();
|
138 |
+
$dataLayer['customerTotalOrderValue'] = $woo_customer->get_total_spent();
|
139 |
+
|
140 |
+
$dataLayer['customerFirstName'] = $woo_customer->get_first_name();
|
141 |
+
$dataLayer['customerLastName'] = $woo_customer->get_last_name();
|
142 |
+
|
143 |
+
$dataLayer['customerBillingFirstName'] = $woo_customer->get_billing_first_name();
|
144 |
+
$dataLayer['customerBillingLastName'] = $woo_customer->get_billing_last_name();
|
145 |
+
$dataLayer['customerBillingCompany'] = $woo_customer->get_billing_company();
|
146 |
+
$dataLayer['customerBillingAddress1'] = $woo_customer->get_billing_address_1();
|
147 |
+
$dataLayer['customerBillingAddress2'] = $woo_customer->get_billing_address_2();
|
148 |
+
$dataLayer['customerBillingCity'] = $woo_customer->get_billing_city();
|
149 |
+
$dataLayer['customerBillingPostcode'] = $woo_customer->get_billing_postcode();
|
150 |
+
$dataLayer['customerBillingCountry'] = $woo_customer->get_billing_country();
|
151 |
+
$dataLayer['customerBillingEmail'] = $woo_customer->get_billing_email();
|
152 |
+
$dataLayer['customerBillingPhone'] = $woo_customer->get_billing_phone();
|
153 |
+
|
154 |
+
$dataLayer['customerShippingFirstName'] = $woo_customer->get_shipping_first_name();
|
155 |
+
$dataLayer['customerShippingLastName'] = $woo_customer->get_shipping_last_name();
|
156 |
+
$dataLayer['customerShippingCompany'] = $woo_customer->get_shipping_company();
|
157 |
+
$dataLayer['customerShippingAddress1'] = $woo_customer->get_shipping_address_1();
|
158 |
+
$dataLayer['customerShippingAddress2'] = $woo_customer->get_shipping_address_2();
|
159 |
+
$dataLayer['customerShippingCity'] = $woo_customer->get_shipping_city();
|
160 |
+
$dataLayer['customerShippingPostcode'] = $woo_customer->get_shipping_postcode();
|
161 |
+
$dataLayer['customerShippingCountry'] = $woo_customer->get_shipping_country();
|
162 |
+
}
|
163 |
+
|
164 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL ] && version_compare( $woo->version, "3.2", ">=" ) ) {
|
165 |
+
$current_cart = $woo->cart;
|
166 |
+
$dataLayer["cartContent"] = array(
|
167 |
+
"totals" => array(
|
168 |
+
"applied_coupons" => $current_cart->get_applied_coupons(),
|
169 |
+
"discount_total" => $current_cart->get_discount_total(),
|
170 |
+
"subtotal" => $current_cart->get_subtotal(),
|
171 |
+
"total" => $current_cart->get_cart_contents_total()
|
172 |
+
),
|
173 |
+
"items" => array()
|
174 |
+
);
|
175 |
+
|
176 |
+
foreach( $current_cart->get_cart() as $cart_item_id => $cart_item_data) {
|
177 |
+
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data["data"], $cart_item_data, $cart_item_id );
|
178 |
+
if ( !apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
179 |
+
continue;
|
180 |
+
}
|
181 |
+
|
182 |
+
$product_id = $product->get_id();
|
183 |
+
$product_type = $product->get_type();
|
184 |
+
|
185 |
+
if ( "variation" == $product_type ) {
|
186 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
187 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
188 |
+
} else {
|
189 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
190 |
+
}
|
191 |
+
|
192 |
+
$remarketing_id = $product_id;
|
193 |
+
$product_sku = $product->get_sku();
|
194 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
195 |
+
$remarketing_id = $product_sku;
|
196 |
+
}
|
197 |
+
|
198 |
+
$_temp_productdata = array(
|
199 |
+
"id" => $remarketing_id,
|
200 |
+
"name" => $product->get_title(),
|
201 |
+
"price" => $product->get_price(),
|
202 |
+
"category" => $product_cat,
|
203 |
+
"stocklevel" => $product->get_stock_quantity(),
|
204 |
+
"quantity" => $cart_item_data["quantity"]
|
205 |
+
);
|
206 |
+
|
207 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
208 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
209 |
+
}
|
210 |
+
|
211 |
+
if ( "variation" == $product_type ) {
|
212 |
+
$_temp_productdata[ "variant" ] = implode(",", $product->get_variation_attributes());
|
213 |
+
}
|
214 |
+
|
215 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "cart" );
|
216 |
+
$dataLayer["cartContent"]["items"][] = $eec_product_array;
|
217 |
+
}
|
218 |
}
|
219 |
|
220 |
if ( is_product_category() || is_product_tag() || is_front_page() || is_shop() ) {
|
221 |
+
$ecomm_pagetype = 'category';
|
222 |
if ( is_front_page() ) {
|
223 |
+
$ecomm_pagetype = 'home';
|
224 |
+
} elseif ( is_search() ) {
|
225 |
+
$ecomm_pagetype = 'searchresults';
|
226 |
}
|
227 |
|
228 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
229 |
+
$dataLayer['ecomm_prodid'] = array();
|
230 |
+
$dataLayer['ecomm_pagetype'] = $ecomm_pagetype;
|
231 |
+
$dataLayer['ecomm_totalvalue'] = 0;
|
232 |
}
|
233 |
+
} elseif ( is_product() ) {
|
234 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) {
|
235 |
$postid = get_the_ID();
|
236 |
$product = wc_get_product( $postid );
|
240 |
|
241 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) {
|
242 |
$product_sku = $product->get_sku();
|
243 |
+
if ( '' != $product_sku ) {
|
244 |
$product_id = $product_sku;
|
245 |
}
|
246 |
}
|
247 |
+
$remarketing_id = (string) $product_id;
|
248 |
+
$product_price = floatval( $product->get_price() );
|
249 |
+
|
250 |
+
$dataLayer['productRatingCounts'] = $product->get_rating_counts();
|
251 |
+
$dataLayer['productAverageRating'] = (float) $product->get_average_rating();
|
252 |
+
$dataLayer['productReviewCount'] = (int) $product->get_review_count();
|
253 |
|
254 |
+
if ( 'variable' != $product->get_type() ) {
|
255 |
+
$dataLayer['productIsVariable'] = 0;
|
256 |
|
257 |
$_temp_productdata = array(
|
258 |
+
'name' => gtm4wp_woocommerce_html_entity_decode( get_the_title() ),
|
259 |
+
'id' => $product_id,
|
260 |
+
'price' => $product_price,
|
261 |
+
'category' => $product_cat,
|
262 |
+
'stocklevel' => $product->get_stock_quantity(),
|
263 |
);
|
264 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
265 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
266 |
+
}
|
267 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'productdetail' );
|
268 |
|
269 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
270 |
+
$dataLayer['ecomm_prodid'] = gtm4wp_prefix_productid( $remarketing_id );
|
271 |
+
$dataLayer['ecomm_pagetype'] = 'product';
|
272 |
+
$dataLayer['ecomm_totalvalue'] = (float) $eec_product_array['price'];
|
273 |
}
|
274 |
|
275 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
276 |
+
$dataLayer['ecommerce'] = array(
|
277 |
+
'currencyCode' => get_woocommerce_currency(),
|
278 |
+
'detail' => array(
|
279 |
+
'products' => array( $eec_product_array ),
|
280 |
+
),
|
281 |
);
|
282 |
}
|
283 |
} else {
|
284 |
+
$dataLayer['productIsVariable'] = 1;
|
285 |
|
286 |
+
$dataLayer['ecomm_prodid'] = gtm4wp_prefix_productid( $remarketing_id );
|
287 |
+
$dataLayer['ecomm_pagetype'] = 'product';
|
288 |
+
$dataLayer['ecomm_totalvalue'] = $product_price;
|
289 |
}
|
290 |
}
|
291 |
+
} elseif ( is_cart() ) {
|
292 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] || $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
293 |
$gtm4wp_cart_products = array();
|
294 |
$gtm4wp_cart_products_remarketing = array();
|
295 |
|
296 |
+
foreach ( $woo->cart->get_cart() as $cart_item_id => $cart_item_data ) {
|
297 |
+
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data['data'], $cart_item_data, $cart_item_id );
|
298 |
|
299 |
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
300 |
continue;
|
303 |
$product_id = $product->get_id();
|
304 |
$product_type = $product->get_type();
|
305 |
|
306 |
+
if ( 'variation' == $product_type ) {
|
307 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id );
|
308 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
309 |
} else {
|
310 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
311 |
}
|
312 |
|
313 |
$remarketing_id = $product_id;
|
314 |
$product_sku = $product->get_sku();
|
315 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
316 |
$remarketing_id = $product_sku;
|
317 |
}
|
318 |
|
319 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
320 |
$_temp_productdata = array(
|
321 |
+
'id' => $remarketing_id,
|
322 |
+
'name' => $product->get_title(),
|
323 |
+
'price' => $product->get_price(),
|
324 |
+
'category' => $product_cat,
|
325 |
+
'stocklevel' => $product->get_stock_quantity(),
|
326 |
+
'quantity' => $cart_item_data['quantity'],
|
327 |
);
|
328 |
|
329 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
330 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
331 |
}
|
332 |
|
333 |
+
if ( 'variation' == $product_type ) {
|
334 |
+
$_temp_productdata['variant'] = implode( ',', $product->get_variation_attributes() );
|
335 |
+
}
|
336 |
+
|
337 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'cart' );
|
338 |
$gtm4wp_cart_products[] = $eec_product_array;
|
339 |
}
|
340 |
|
342 |
}
|
343 |
|
344 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
345 |
+
$dataLayer['ecomm_prodid'] = $gtm4wp_cart_products_remarketing;
|
346 |
+
$dataLayer['ecomm_pagetype'] = 'cart';
|
347 |
if ( ! $woo->cart->prices_include_tax ) {
|
348 |
$cart_total = $woo->cart->cart_contents_total;
|
349 |
} else {
|
350 |
$cart_total = $woo->cart->cart_contents_total + $woo->cart->tax_total;
|
351 |
}
|
352 |
+
$dataLayer['ecomm_totalvalue'] = (float) $cart_total;
|
353 |
}
|
354 |
|
355 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
356 |
+
$dataLayer['ecommerce'] = array(
|
357 |
+
'currencyCode' => get_woocommerce_currency(),
|
358 |
+
'checkout' => array(
|
359 |
+
'actionField' => array(
|
360 |
+
'step' => 1,
|
361 |
),
|
362 |
+
'products' => $gtm4wp_cart_products,
|
363 |
+
),
|
364 |
);
|
365 |
}
|
366 |
}
|
367 |
+
} elseif ( is_order_received_page() ) {
|
368 |
+
$do_not_flag_tracked_order = (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG ] );
|
369 |
+
$order_id = empty( $_GET['order'] ) ? ( $GLOBALS['wp']->query_vars['order-received'] ? $GLOBALS['wp']->query_vars['order-received'] : 0 ) : absint( $_GET['order'] );
|
370 |
$order_id_filtered = apply_filters( 'woocommerce_thankyou_order_id', $order_id );
|
371 |
+
if ( '' != $order_id_filtered ) {
|
372 |
$order_id = $order_id_filtered;
|
373 |
}
|
374 |
|
375 |
+
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
|
376 |
|
377 |
if ( $order_id > 0 ) {
|
378 |
$order = wc_get_order( $order_id );
|
392 |
}
|
393 |
}
|
394 |
|
395 |
+
if ( ( 1 == get_post_meta( $order_id, '_ga_tracked', true ) ) && ! $do_not_flag_tracked_order ) {
|
396 |
+
unset( $order );
|
397 |
+
}
|
398 |
+
|
399 |
+
if ( isset( $_COOKIE[ 'gtm4wp_orderid_tracked' ] ) && ( $_COOKIE[ 'gtm4wp_orderid_tracked' ] == $order_id ) && ! $do_not_flag_tracked_order ) {
|
400 |
unset( $order );
|
401 |
}
|
402 |
|
403 |
if ( isset( $order ) ) {
|
404 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX ] ) {
|
405 |
+
$order_revenue = floatval( $order->get_total() - $order->get_total_tax() );
|
406 |
} else {
|
407 |
+
$order_revenue = floatval( $order->get_total() );
|
408 |
+
}
|
409 |
+
|
410 |
+
if ( $gtm4wp_is_woocommerce3 ) {
|
411 |
+
$order_shipping_cost = floatval( $order->get_shipping_total() );
|
412 |
+
} else {
|
413 |
+
$order_shipping_cost = floatval( $order->get_total_shipping() );
|
414 |
+
}
|
415 |
+
|
416 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING ] ) {
|
417 |
+
$order_revenue -= $order_shipping_cost;
|
418 |
}
|
419 |
|
420 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
421 |
+
$dataLayer['transactionId'] = $order->get_order_number();
|
422 |
+
$dataLayer['transactionDate'] = date( 'c' );
|
423 |
+
$dataLayer['transactionType'] = 'sale';
|
424 |
+
$dataLayer['transactionAffiliation'] = '';
|
425 |
+
$dataLayer['transactionTotal'] = $order_revenue;
|
426 |
+
$dataLayer['transactionShipping'] = $order_shipping_cost;
|
427 |
+
$dataLayer['transactionTax'] = floatval( $order->get_total_tax() );
|
428 |
+
$dataLayer['transactionPaymentType'] = ( $gtm4wp_is_woocommerce3 ? $order->get_payment_method_title() : $order->payment_method_title );
|
429 |
+
$dataLayer['transactionCurrency'] = get_woocommerce_currency();
|
430 |
+
$dataLayer['transactionShippingMethod'] = $order->get_shipping_method();
|
431 |
+
$dataLayer['transactionPromoCode'] = implode( ', ', $order->get_used_coupons() );
|
|
|
|
|
|
|
|
|
432 |
}
|
433 |
|
434 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
435 |
+
$dataLayer['ecommerce'] = array(
|
436 |
+
'currencyCode' => get_woocommerce_currency(),
|
437 |
+
'purchase' => array(
|
438 |
+
'actionField' => array(
|
439 |
+
'id' => $order->get_order_number(),
|
440 |
+
'affiliation' => '',
|
441 |
+
'revenue' => $order_revenue,
|
442 |
+
'tax' => floatval( $order->get_total_tax() ),
|
443 |
+
'shipping' => floatval( $gtm4wp_is_woocommerce3 ? $order->get_shipping_total() : $order->get_total_shipping() ),
|
444 |
+
'coupon' => implode( ', ', $order->get_used_coupons() ),
|
445 |
+
),
|
446 |
+
),
|
447 |
);
|
448 |
}
|
449 |
|
450 |
+
$_products = array();
|
451 |
+
$_sumprice = 0;
|
452 |
$_product_ids = array();
|
453 |
|
454 |
if ( $order->get_items() ) {
|
458 |
continue;
|
459 |
}
|
460 |
|
461 |
+
$product = ( $gtm4wp_is_woocommerce3 ? $item->get_product() : $order->get_product_from_item( $item ) );
|
462 |
|
463 |
$product_id = $product->get_id();
|
464 |
$product_type = $product->get_type();
|
465 |
|
466 |
+
if ( 'variation' == $product_type ) {
|
467 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id );
|
468 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
469 |
} else {
|
470 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
471 |
}
|
472 |
|
473 |
$remarketing_id = $product_id;
|
474 |
$product_sku = $product->get_sku();
|
475 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
476 |
$remarketing_id = $product_sku;
|
477 |
}
|
478 |
|
479 |
+
$product_price = floatval( $order->get_item_total( $item ) );
|
480 |
$_temp_productdata = array(
|
481 |
+
'id' => $remarketing_id,
|
482 |
+
'name' => $product->get_title(),
|
483 |
+
'sku' => $product_sku ? $product_sku : $product_id,
|
484 |
+
'category' => $product_cat,
|
485 |
+
'price' => $product_price,
|
486 |
+
'currency' => get_woocommerce_currency(),
|
487 |
+
'stocklevel' => $product->get_stock_quantity(),
|
488 |
+
'quantity' => $item['qty'],
|
489 |
);
|
490 |
|
491 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
492 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
493 |
}
|
494 |
|
495 |
+
if ( 'variation' == $product_type ) {
|
496 |
+
$_temp_productdata['variant'] = implode( ',', $product->get_variation_attributes() );
|
497 |
+
}
|
498 |
+
|
499 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'purchase' );
|
500 |
+
$_products[] = $eec_product_array;
|
501 |
|
502 |
+
$_sumprice += $product_price * $eec_product_array['quantity'];
|
503 |
$_product_ids[] = gtm4wp_prefix_productid( $remarketing_id );
|
504 |
}
|
505 |
}
|
506 |
|
507 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
508 |
+
$dataLayer['transactionProducts'] = $_products;
|
509 |
+
$dataLayer['event'] = 'gtm4wp.orderCompleted';
|
510 |
}
|
511 |
|
512 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
513 |
+
$dataLayer['ecommerce']['purchase']['products'] = $_products;
|
514 |
+
$dataLayer['event'] = 'gtm4wp.orderCompletedEEC';
|
515 |
}
|
516 |
|
517 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
518 |
+
$dataLayer['ecomm_prodid'] = $_product_ids;
|
519 |
+
$dataLayer['ecomm_pagetype'] = 'purchase';
|
520 |
+
$dataLayer['ecomm_totalvalue'] = (float) $_sumprice;
|
521 |
}
|
522 |
|
523 |
+
if ( ! $do_not_flag_tracked_order ) {
|
524 |
update_post_meta( $order_id, '_ga_tracked', 1 );
|
525 |
}
|
526 |
}
|
527 |
+
} elseif ( is_checkout() ) {
|
528 |
if ( ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) ) {
|
529 |
$gtm4wp_checkout_products = array();
|
530 |
$gtm4wp_checkout_products_remarketing = array();
|
531 |
$gtm4wp_totalvalue = 0;
|
532 |
|
533 |
+
foreach ( $woo->cart->get_cart() as $cart_item_id => $cart_item_data ) {
|
534 |
+
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data['data'], $cart_item_data, $cart_item_id );
|
535 |
|
536 |
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
537 |
continue;
|
538 |
}
|
539 |
|
540 |
+
$product_id = $product->get_id();
|
541 |
$product_type = $product->get_type();
|
542 |
|
543 |
+
if ( 'variation' == $product_type ) {
|
544 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id );
|
545 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
546 |
} else {
|
547 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
548 |
}
|
549 |
|
550 |
$remarketing_id = $product_id;
|
551 |
$product_sku = $product->get_sku();
|
552 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
553 |
$remarketing_id = $product_sku;
|
554 |
}
|
555 |
|
556 |
$_temp_productdata = array(
|
557 |
+
'id' => $remarketing_id,
|
558 |
+
'name' => $product->get_title(),
|
559 |
+
'price' => $product->get_price(),
|
560 |
+
'category' => $product_cat,
|
561 |
+
'stocklevel' => $product->get_stock_quantity(),
|
562 |
+
'quantity' => $cart_item_data['quantity'],
|
563 |
);
|
564 |
|
565 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
566 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
567 |
}
|
568 |
|
569 |
+
if ( 'variation' == $product_type ) {
|
570 |
+
$_temp_productdata['variant'] = implode( ',', $product->get_variation_attributes() );
|
571 |
+
}
|
572 |
+
|
573 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'checkout' );
|
574 |
$gtm4wp_checkout_products[] = $eec_product_array;
|
575 |
|
576 |
$gtm4wp_checkout_products_remarketing[] = gtm4wp_prefix_productid( $remarketing_id );
|
577 |
+
$gtm4wp_totalvalue += $eec_product_array['quantity'] * $eec_product_array['price'];
|
578 |
} // end foreach cart item
|
579 |
|
580 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
581 |
+
$dataLayer['ecomm_prodid'] = $gtm4wp_checkout_products_remarketing;
|
582 |
+
$dataLayer['ecomm_pagetype'] = 'cart';
|
583 |
+
$dataLayer['ecomm_totalvalue'] = (float) $gtm4wp_totalvalue;
|
584 |
}
|
585 |
|
586 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
587 |
+
$dataLayer['ecommerce'] = array(
|
588 |
+
'currencyCode' => get_woocommerce_currency(),
|
589 |
+
'checkout' => array(
|
590 |
+
'actionField' => array(
|
591 |
+
'step' => 1 + (int) $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ],
|
592 |
),
|
593 |
+
'products' => $gtm4wp_checkout_products,
|
594 |
+
),
|
595 |
);
|
596 |
|
597 |
+
gtm4wp_woocommerce_addjs(
|
598 |
+
'
|
599 |
+
window.gtm4wp_checkout_products = ' . json_encode( $gtm4wp_checkout_products ) . ';
|
600 |
+
window.gtm4wp_checkout_step_offset = ' . (int) $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] . ';'
|
601 |
);
|
602 |
}
|
603 |
}
|
604 |
} else {
|
605 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
606 |
+
$dataLayer['ecomm_pagetype'] = 'other';
|
607 |
}
|
608 |
}
|
609 |
|
610 |
+
if ( isset( $_COOKIE['gtm4wp_product_readded_to_cart'] ) ) {
|
611 |
+
$cart_item = $woo->cart->get_cart_item( $_COOKIE['gtm4wp_product_readded_to_cart'] );
|
612 |
+
if ( ! empty( $cart_item ) ) {
|
613 |
+
$product = $cart_item['data'];
|
614 |
|
615 |
$product_id = $product->get_id();
|
616 |
$product_type = $product->get_type();
|
617 |
|
618 |
+
if ( 'variation' == $product_type ) {
|
619 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id );
|
620 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
621 |
} else {
|
622 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
623 |
}
|
624 |
|
625 |
$remarketing_id = $product_id;
|
626 |
$product_sku = $product->get_sku();
|
627 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
628 |
$remarketing_id = $product_sku;
|
629 |
}
|
630 |
|
631 |
+
$dataLayer['ecommerce']['currencyCode'] = get_woocommerce_currency();
|
632 |
+
$dataLayer['ecommerce']['add']['products'][] = array(
|
633 |
+
'name' => $product->get_title(),
|
634 |
+
'id' => $remarketing_id,
|
635 |
+
'price' => $product->get_price(),
|
636 |
+
'category' => $product_cat,
|
637 |
+
'stocklevel' => $product->get_stock_quantity(),
|
638 |
+
'quantity' => $cart_item['quantity'],
|
639 |
);
|
640 |
|
641 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
642 |
+
$dataLayer["ecommerce"]["add"]["products"][0][ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
643 |
+
}
|
644 |
+
|
645 |
+
if ( 'variation' == $product_type ) {
|
646 |
+
$dataLayer['ecommerce']['add'][0]['variant'] = implode( ',', $product->get_variation_attributes() );
|
647 |
}
|
648 |
}
|
649 |
|
650 |
gtm4wp_woocommerce_addjs( "document.cookie = 'gtm4wp_product_readded_to_cart=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';" );
|
651 |
+
unset( $_COOKIE['gtm4wp_product_readded_to_cart'] );
|
652 |
}
|
653 |
|
654 |
return $dataLayer;
|
668 |
|
669 |
$remarketing_id = $product_id;
|
670 |
$product_sku = $product->get_sku();
|
671 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
672 |
$remarketing_id = $product_sku;
|
673 |
}
|
674 |
|
675 |
$_temp_productdata = array(
|
676 |
+
'id' => $remarketing_id,
|
677 |
+
'name' => $product->get_title(),
|
678 |
+
'sku' => $product_sku ? $product_sku : $product_id,
|
679 |
+
'category' => $product_cat,
|
680 |
+
'price' => $product->get_price(),
|
681 |
+
'currency' => get_woocommerce_currency(),
|
682 |
+
'stocklevel' => $product->get_stock_quantity(),
|
683 |
);
|
684 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
685 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
686 |
+
}
|
687 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'addtocartsingle' );
|
688 |
|
689 |
+
foreach ( $eec_product_array as $eec_product_array_key => $eec_product_array_value ) {
|
690 |
+
echo '<input type="hidden" name="gtm4wp_' . esc_attr( $eec_product_array_key ) . '" value="' . esc_attr( $eec_product_array_value ) . '" />' . "\n";
|
691 |
}
|
692 |
}
|
693 |
|
694 |
+
$GLOBALS['gtm4wp_cart_item_proddata'] = '';
|
695 |
+
function gtm4wp_woocommerce_cart_item_product_filter( $product, $cart_item = '', $cart_id = '' ) {
|
696 |
global $gtm4wp_options, $gtm4wp_is_woocommerce3;
|
697 |
|
698 |
$product_id = $product->get_id();
|
699 |
$product_type = $product->get_type();
|
700 |
|
701 |
+
if ( 'variation' == $product_type ) {
|
702 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id );
|
703 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
704 |
} else {
|
705 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
706 |
}
|
707 |
|
708 |
$remarketing_id = $product_id;
|
709 |
$product_sku = $product->get_sku();
|
710 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
711 |
$remarketing_id = $product_sku;
|
712 |
}
|
713 |
|
714 |
$_temp_productdata = array(
|
715 |
+
'id' => $remarketing_id,
|
716 |
+
'name' => $product->get_title(),
|
717 |
+
'price' => $product->get_price(),
|
718 |
+
'category' => $product_cat,
|
719 |
+
'productlink' => apply_filters( 'the_permalink', get_permalink(), 0 ),
|
720 |
+
'variant' => '',
|
721 |
+
'stocklevel' => $product->get_stock_quantity(),
|
722 |
);
|
723 |
|
724 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
725 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
726 |
+
} else {
|
727 |
+
$_temp_productdata[ "brand" ] = "";
|
728 |
+
}
|
729 |
+
|
730 |
+
if ( 'variation' == $product_type ) {
|
731 |
+
$_temp_productdata['variant'] = implode( ',', $product->get_variation_attributes() );
|
732 |
}
|
733 |
|
734 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'cart' );
|
735 |
+
$GLOBALS['gtm4wp_cart_item_proddata'] = $eec_product_array;
|
736 |
|
737 |
return $product;
|
738 |
}
|
739 |
|
740 |
function gtm4wp_woocommerce_cart_item_remove_link_filter( $remove_from_cart_link ) {
|
741 |
+
if ( ! isset( $GLOBALS['gtm4wp_cart_item_proddata'] ) ) {
|
742 |
return $remove_from_cart_link;
|
743 |
}
|
744 |
|
745 |
+
if ( ! is_array( $GLOBALS['gtm4wp_cart_item_proddata'] ) ) {
|
746 |
return $remove_from_cart_link;
|
747 |
}
|
748 |
|
749 |
+
$cartlink_with_data = sprintf(
|
750 |
+
'data-gtm4wp_product_id="%s" data-gtm4wp_product_name="%s" data-gtm4wp_product_price="%s" data-gtm4wp_product_cat="%s" data-gtm4wp_product_url="%s" data-gtm4wp_product_variant="%s" data-gtm4wp_product_stocklevel="%s" data-gtm4wp_product_brand="%s" href="',
|
751 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['id'] ),
|
752 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['name'] ),
|
753 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['price'] ),
|
754 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['category'] ),
|
755 |
+
esc_url( $GLOBALS['gtm4wp_cart_item_proddata']['productlink'] ),
|
756 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['variant'] ),
|
757 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['stocklevel'] ),
|
758 |
+
esc_attr( $GLOBALS['gtm4wp_cart_item_proddata']['brand'] )
|
759 |
);
|
760 |
+
$GLOBALS['gtm4wp_cart_item_proddata'] = '';
|
761 |
|
762 |
return gtm4wp_str_replace_first( 'href="', $cartlink_with_data, $remove_from_cart_link );
|
763 |
}
|
765 |
function gtp4wp_woocommerce_reset_loop() {
|
766 |
global $woocommerce_loop;
|
767 |
|
768 |
+
$woocommerce_loop['listtype'] = '';
|
769 |
}
|
770 |
|
771 |
function gtm4wp_woocommerce_add_related_to_loop( $arg ) {
|
772 |
global $woocommerce_loop;
|
773 |
|
774 |
+
$woocommerce_loop['listtype'] = __( 'Related Products', 'duracelltomi-google-tag-manager' );
|
775 |
|
776 |
return $arg;
|
777 |
}
|
779 |
function gtm4wp_woocommerce_add_cross_sell_to_loop( $arg ) {
|
780 |
global $woocommerce_loop;
|
781 |
|
782 |
+
$woocommerce_loop['listtype'] = __( 'Cross-Sell Products', 'duracelltomi-google-tag-manager' );
|
783 |
|
784 |
return $arg;
|
785 |
}
|
787 |
function gtm4wp_woocommerce_add_upsells_to_loop( $arg ) {
|
788 |
global $woocommerce_loop;
|
789 |
|
790 |
+
$woocommerce_loop['listtype'] = __( 'Upsell Products', 'duracelltomi-google-tag-manager' );
|
791 |
|
792 |
return $arg;
|
793 |
}
|
802 |
$productitem = ob_get_contents();
|
803 |
ob_end_clean();
|
804 |
|
805 |
+
if ( 'content-widget-product.php' == $template_name ) {
|
806 |
+
$product_id = $product->get_id();
|
807 |
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
808 |
|
809 |
$remarketing_id = $product_id;
|
810 |
$product_sku = $product->get_sku();
|
811 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
812 |
$remarketing_id = $product_sku;
|
813 |
}
|
814 |
|
815 |
$_temp_productdata = array(
|
816 |
+
'id' => $remarketing_id,
|
817 |
+
'name' => $product->get_title(),
|
818 |
+
'price' => $product->get_price(),
|
819 |
+
'category' => $product_cat,
|
820 |
+
'productlink' => apply_filters( 'the_permalink', get_permalink(), 0 ),
|
821 |
+
'listname' => $gtm4wp_last_widget_title,
|
822 |
+
'listposition' => $gtm4wp_product_counter,
|
823 |
+
'stocklevel' => $product->get_stock_quantity(),
|
824 |
);
|
825 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
826 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
827 |
+
} else {
|
828 |
+
$_temp_productdata[ "brand" ] = "";
|
829 |
+
}
|
830 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'widgetproduct' );
|
831 |
+
|
832 |
+
$productlink_with_data = sprintf(
|
833 |
+
'data-gtm4wp_product_id="%s" data-gtm4wp_product_name="%s" data-gtm4wp_product_price="%s" data-gtm4wp_product_cat="%s" data-gtm4wp_product_url="%s" data-gtm4wp_productlist_name="%s" data-gtm4wp_product_listposition="%s" data-gtm4wp_product_stocklevel="%s" data-gtm4wp_product_brand="%s" href="',
|
834 |
+
esc_attr( $eec_product_array['id'] ),
|
835 |
+
esc_attr( $eec_product_array['name'] ),
|
836 |
+
esc_attr( $eec_product_array['price'] ),
|
837 |
+
esc_attr( $eec_product_array['category'] ),
|
838 |
+
esc_url( $eec_product_array['productlink'] ),
|
839 |
+
esc_attr( $eec_product_array['listname'] ),
|
840 |
+
esc_attr( $eec_product_array['listposition'] ),
|
841 |
+
esc_attr( $eec_product_array['stocklevel'] ),
|
842 |
+
esc_attr( $eec_product_array[ "brand" ] )
|
843 |
);
|
844 |
|
845 |
$gtm4wp_product_counter++;
|
853 |
function gtm4wp_widget_title_filter( $widget_title ) {
|
854 |
global $gtm4wp_product_counter, $gtm4wp_last_widget_title;
|
855 |
|
856 |
+
$gtm4wp_product_counter = 1;
|
857 |
+
$gtm4wp_last_widget_title = $widget_title . __( ' (widget)', 'duracelltomi-google-tag-manager' );
|
858 |
|
859 |
return $widget_title;
|
860 |
}
|
862 |
function gtm4wp_before_recent_products_loop() {
|
863 |
global $woocommerce_loop;
|
864 |
|
865 |
+
$woocommerce_loop['listtype'] = __( 'Recent Products', 'duracelltomi-google-tag-manager' );
|
866 |
}
|
867 |
|
868 |
function gtm4wp_before_sale_products_loop() {
|
869 |
global $woocommerce_loop;
|
870 |
|
871 |
+
$woocommerce_loop['listtype'] = __( 'Sale Products', 'duracelltomi-google-tag-manager' );
|
872 |
}
|
873 |
|
874 |
function gtm4wp_before_best_selling_products_loop() {
|
875 |
global $woocommerce_loop;
|
876 |
|
877 |
+
$woocommerce_loop['listtype'] = __( 'Best Selling Products', 'duracelltomi-google-tag-manager' );
|
878 |
}
|
879 |
|
880 |
function gtm4wp_before_top_rated_products_loop() {
|
881 |
global $woocommerce_loop;
|
882 |
|
883 |
+
$woocommerce_loop['listtype'] = __( 'Top Rated Products', 'duracelltomi-google-tag-manager' );
|
884 |
}
|
885 |
|
886 |
function gtm4wp_before_featured_products_loop() {
|
887 |
global $woocommerce_loop;
|
888 |
|
889 |
+
$woocommerce_loop['listtype'] = __( 'Featured Products', 'duracelltomi-google-tag-manager' );
|
890 |
}
|
891 |
|
892 |
function gtm4wp_before_related_products_loop() {
|
893 |
global $woocommerce_loop;
|
894 |
|
895 |
+
$woocommerce_loop['listtype'] = __( 'Related Products', 'duracelltomi-google-tag-manager' );
|
896 |
}
|
897 |
|
898 |
function gtm4wp_woocommerce_before_shop_loop_item() {
|
899 |
global $product, $woocommerce_loop, $wp_query, $gtm4wp_options;
|
900 |
|
901 |
+
if ( ! isset( $product ) ) {
|
902 |
return;
|
903 |
}
|
904 |
|
905 |
+
$product_id = $product->get_id();
|
906 |
|
907 |
+
$product_cat = '';
|
908 |
if ( is_product_category() ) {
|
909 |
global $wp_query;
|
910 |
$cat_obj = $wp_query->get_queried_object();
|
918 |
}
|
919 |
|
920 |
if ( is_search() ) {
|
921 |
+
$list_name = __( 'Search Results', 'duracelltomi-google-tag-manager' );
|
922 |
+
} elseif ( isset( $woocommerce_loop['listtype'] ) && ( $woocommerce_loop['listtype'] != '' ) ) {
|
923 |
+
$list_name = $woocommerce_loop['listtype'];
|
924 |
} else {
|
925 |
+
$list_name = __( 'General Product List', 'duracelltomi-google-tag-manager' );
|
926 |
}
|
927 |
|
928 |
+
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
|
929 |
+
$posts_per_page = get_query_var( 'posts_per_page' );
|
930 |
if ( $posts_per_page < 1 ) {
|
931 |
$posts_per_page = 1;
|
932 |
}
|
933 |
|
934 |
$remarketing_id = $product_id;
|
935 |
$product_sku = $product->get_sku();
|
936 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( '' != $product_sku ) ) {
|
937 |
$remarketing_id = $product_sku;
|
938 |
}
|
939 |
|
940 |
$_temp_productdata = array(
|
941 |
+
'id' => $remarketing_id,
|
942 |
+
'name' => $product->get_title(),
|
943 |
+
'price' => $product->get_price(),
|
944 |
+
'category' => $product_cat,
|
945 |
+
'productlink' => apply_filters( 'the_permalink', get_permalink(), 0 ),
|
946 |
+
'listname' => $list_name,
|
947 |
+
'listposition' => $woocommerce_loop['loop'] + ( $posts_per_page * ( $paged - 1 ) ),
|
948 |
+
'stocklevel' => $product->get_stock_quantity(),
|
949 |
);
|
950 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
951 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $remarketing_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
952 |
+
} else {
|
953 |
+
$_temp_productdata[ "brand" ] = "";
|
954 |
+
}
|
955 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'productlist' );
|
956 |
+
|
957 |
+
printf(
|
958 |
+
'<span class="gtm4wp_productdata" style="display:none; visibility:hidden;" data-gtm4wp_product_id="%s" data-gtm4wp_product_name="%s" data-gtm4wp_product_price="%s" data-gtm4wp_product_cat="%s" data-gtm4wp_product_url="%s" data-gtm4wp_product_listposition="%s" data-gtm4wp_productlist_name="%s" data-gtm4wp_product_stocklevel="%s" data-gtm4wp_product_brand="%s"></span>',
|
959 |
+
esc_attr( $eec_product_array['id'] ),
|
960 |
+
esc_attr( $eec_product_array['name'] ),
|
961 |
+
esc_attr( $eec_product_array['price'] ),
|
962 |
+
esc_attr( $eec_product_array['category'] ),
|
963 |
+
esc_url( $eec_product_array['productlink'] ),
|
964 |
+
esc_attr( $eec_product_array['listposition'] ),
|
965 |
+
esc_attr( $eec_product_array['listname'] ),
|
966 |
+
esc_attr( $eec_product_array['stocklevel'] ),
|
967 |
+
esc_attr( $eec_product_array[ "brand" ] )
|
968 |
);
|
969 |
}
|
970 |
|
971 |
function gtm4wp_woocommerce_cart_item_restored( $cart_item_key ) {
|
972 |
+
setcookie( 'gtm4wp_product_readded_to_cart', $cart_item_key );
|
973 |
}
|
974 |
|
975 |
function gtm4wp_woocommerce_enqueue_scripts() {
|
976 |
+
global $gtm4wp_options, $gtp4wp_plugin_url;
|
977 |
|
978 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
979 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC, false );
|
980 |
+
wp_enqueue_script( 'gtm4wp-woocommerce-classic', $gtp4wp_plugin_url . 'js/gtm4wp-woocommerce-classic.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
981 |
}
|
982 |
|
983 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
984 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC, false );
|
985 |
+
wp_enqueue_script( 'gtm4wp-woocommerce-enhanced', $gtp4wp_plugin_url . 'js/gtm4wp-woocommerce-enhanced.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
986 |
}
|
987 |
}
|
988 |
|
990 |
global $gtm4wp_options, $gtm4wp_datalayer_name;
|
991 |
|
992 |
$dataLayer = array(
|
993 |
+
'event' => 'gtm4wp.changeDetailViewEEC',
|
994 |
);
|
995 |
|
996 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) {
|
1002 |
|
1003 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) {
|
1004 |
$product_sku = $product->get_sku();
|
1005 |
+
if ( '' != $product_sku ) {
|
1006 |
$product_id = $product_sku;
|
1007 |
}
|
1008 |
}
|
1009 |
+
$remarketing_id = (string) $product_id;
|
1010 |
+
$product_price = floatval( $product->get_price() );
|
1011 |
|
1012 |
+
if ( 'variable' != $product->get_type() ) {
|
1013 |
$_temp_productdata = array(
|
1014 |
+
'name' => gtm4wp_woocommerce_html_entity_decode( get_the_title() ),
|
1015 |
+
'id' => $product_id,
|
1016 |
+
'price' => $product_price,
|
1017 |
+
'category' => $product_cat,
|
1018 |
+
'stocklevel' => $product->get_stock_quantity(),
|
1019 |
);
|
1020 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] != "" ) {
|
1021 |
+
$_temp_productdata[ "brand" ] = gtm4wp_woocommerce_getproductterm( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ] );
|
1022 |
+
} else {
|
1023 |
+
$_temp_productdata[ "brand" ] = "";
|
1024 |
+
}
|
1025 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, 'productdetail' );
|
1026 |
|
1027 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
1028 |
+
$dataLayer['ecomm_prodid'] = gtm4wp_prefix_productid( $remarketing_id );
|
1029 |
+
$dataLayer['ecomm_pagetype'] = 'product';
|
1030 |
+
$dataLayer['ecomm_totalvalue'] = (float) $eec_product_array['price'];
|
1031 |
}
|
1032 |
|
1033 |
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1034 |
+
$dataLayer['ecommerce'] = array(
|
1035 |
+
'currencyCode' => get_woocommerce_currency(),
|
1036 |
+
'detail' => array(
|
1037 |
+
'products' => array( $eec_product_array ),
|
1038 |
+
),
|
1039 |
);
|
1040 |
}
|
1041 |
} else {
|
1042 |
+
$dataLayer['ecomm_prodid'] = gtm4wp_prefix_productid( $remarketing_id );
|
1043 |
+
$dataLayer['ecomm_pagetype'] = 'product';
|
1044 |
+
$dataLayer['ecomm_totalvalue'] = $product_price;
|
1045 |
}
|
1046 |
}
|
1047 |
|
1048 |
echo '
|
1049 |
<script>
|
1050 |
+
' . $gtm4wp_datalayer_name . '.push(' . json_encode( $dataLayer ) . ');
|
1051 |
</script>';
|
1052 |
}
|
1053 |
|
1054 |
// do not add filter if someone enabled WooCommerce integration without an activated WooCommerce plugin
|
1055 |
+
if ( function_exists( 'WC' ) ) {
|
1056 |
+
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, 'gtm4wp_woocommerce_datalayer_filter_items' );
|
1057 |
+
|
1058 |
+
add_filter( 'loop_end', 'gtp4wp_woocommerce_reset_loop' );
|
1059 |
+
add_action( 'woocommerce_before_shop_loop_item', 'gtm4wp_woocommerce_before_shop_loop_item' );
|
1060 |
+
add_action( 'woocommerce_after_add_to_cart_button', 'gtm4wp_woocommerce_single_add_to_cart_tracking' );
|
1061 |
+
|
1062 |
+
// add_action( "wp_footer", "gtm4wp_woocommerce_wp_footer" );
|
1063 |
+
add_action( 'wp_enqueue_scripts', 'gtm4wp_woocommerce_enqueue_scripts' );
|
1064 |
+
add_filter( GTM4WP_WPACTION_ADDGLOBALVARS, 'gtm4wp_woocommerce_addglobalvars' );
|
1065 |
+
|
1066 |
+
if ( true === $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1067 |
+
// add_action( "wp_footer", "gtm4wp_woocommerce_enhanced_ecom_product_click" );
|
1068 |
+
add_action( 'woocommerce_before_template_part', 'gtm4wp_woocommerce_before_template_part' );
|
1069 |
+
add_action( 'woocommerce_after_template_part', 'gtm4wp_woocommerce_after_template_part' );
|
1070 |
+
add_filter( 'widget_title', 'gtm4wp_widget_title_filter' );
|
1071 |
+
add_action( 'wc_quick_view_before_single_product', 'gtm4wp_wc_quick_view_before_single_product' );
|
1072 |
+
|
1073 |
+
add_filter( 'woocommerce_cart_item_product', 'gtm4wp_woocommerce_cart_item_product_filter' );
|
1074 |
+
add_filter( 'woocommerce_cart_item_remove_link', 'gtm4wp_woocommerce_cart_item_remove_link_filter' );
|
1075 |
+
add_action( 'woocommerce_cart_item_restored', 'gtm4wp_woocommerce_cart_item_restored' );
|
1076 |
+
|
1077 |
+
add_filter( 'woocommerce_related_products_args', 'gtm4wp_woocommerce_add_related_to_loop' );
|
1078 |
+
add_filter( 'woocommerce_related_products_columns', 'gtm4wp_woocommerce_add_related_to_loop' );
|
1079 |
+
add_filter( 'woocommerce_cross_sells_columns', 'gtm4wp_woocommerce_add_cross_sell_to_loop' );
|
1080 |
+
add_filter( 'woocommerce_upsells_columns', 'gtm4wp_woocommerce_add_upsells_to_loop' );
|
1081 |
+
|
1082 |
+
add_action( 'woocommerce_shortcode_before_recent_products_loop', 'gtm4wp_before_recent_products_loop' );
|
1083 |
+
add_action( 'woocommerce_shortcode_before_sale_products_loop', 'gtm4wp_before_sale_products_loop' );
|
1084 |
+
add_action( 'woocommerce_shortcode_before_best_selling_products_loop', 'gtm4wp_before_best_selling_products_loop' );
|
1085 |
+
add_action( 'woocommerce_shortcode_before_top_rated_products_loop', 'gtm4wp_before_top_rated_products_loop' );
|
1086 |
+
add_action( 'woocommerce_shortcode_before_featured_products_loop', 'gtm4wp_before_featured_products_loop' );
|
1087 |
+
add_action( 'woocommerce_shortcode_before_related_products_loop', 'gtm4wp_before_related_products_loop' );
|
1088 |
}
|
1089 |
+
}
|
integration/youtube.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?php
|
2 |
function gtm4wp_youtube( $return, $url, $data ) {
|
3 |
-
$site_url
|
4 |
$site_url_parts = parse_url( $site_url );
|
5 |
|
6 |
-
if ( false !== strpos( $return,
|
7 |
-
return str_replace(
|
8 |
} else {
|
9 |
return $return;
|
10 |
}
|
11 |
}
|
12 |
|
13 |
-
add_filter(
|
14 |
|
15 |
if ( ! is_admin() ) {
|
16 |
-
$in_footer = apply_filters( 'gtm4wp_youtube', false);
|
17 |
-
wp_enqueue_script(
|
18 |
-
}
|
1 |
<?php
|
2 |
function gtm4wp_youtube( $return, $url, $data ) {
|
3 |
+
$site_url = site_url();
|
4 |
$site_url_parts = parse_url( $site_url );
|
5 |
|
6 |
+
if ( false !== strpos( $return, 'youtube.com' ) ) {
|
7 |
+
return str_replace( 'feature=oembed', 'feature=oembed&enablejsapi=1&origin=' . $site_url_parts['scheme'] . '://' . $site_url_parts['host'], $return );
|
8 |
} else {
|
9 |
return $return;
|
10 |
}
|
11 |
}
|
12 |
|
13 |
+
add_filter( 'oembed_result', 'gtm4wp_youtube', 10, 3 );
|
14 |
|
15 |
if ( ! is_admin() ) {
|
16 |
+
$in_footer = apply_filters( 'gtm4wp_youtube', false );
|
17 |
+
wp_enqueue_script( 'gtm4wp-youtube', $gtp4wp_plugin_url . 'js/gtm4wp-youtube.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
18 |
+
}
|
js/admin-subtabs.js
CHANGED
@@ -4,7 +4,7 @@ var adminsubtabs = {
|
|
4 |
1: {
|
5 |
"posts": {
|
6 |
tabtext: gtm4wp.posttabtitle,
|
7 |
-
numitems:
|
8 |
},
|
9 |
"search": {
|
10 |
tabtext: gtm4wp.searchtabtitle,
|
@@ -24,7 +24,7 @@ var adminsubtabs = {
|
|
24 |
},
|
25 |
"weather": {
|
26 |
tabtext: gtm4wp.weathertabtitle,
|
27 |
-
numitems:
|
28 |
},
|
29 |
"site": {
|
30 |
tabtext: gtm4wp.sitetabtitle,
|
@@ -67,7 +67,7 @@ var adminsubtabs = {
|
|
67 |
},
|
68 |
"int-wc": {
|
69 |
tabtext: gtm4wp.wctabtitle,
|
70 |
-
numitems:
|
71 |
},
|
72 |
"int-google-optimize": {
|
73 |
tabtext: gtm4wp.gotabtitle,
|
4 |
1: {
|
5 |
"posts": {
|
6 |
tabtext: gtm4wp.posttabtitle,
|
7 |
+
numitems: 11
|
8 |
},
|
9 |
"search": {
|
10 |
tabtext: gtm4wp.searchtabtitle,
|
24 |
},
|
25 |
"weather": {
|
26 |
tabtext: gtm4wp.weathertabtitle,
|
27 |
+
numitems: 6
|
28 |
},
|
29 |
"site": {
|
30 |
tabtext: gtm4wp.sitetabtitle,
|
67 |
},
|
68 |
"int-wc": {
|
69 |
tabtext: gtm4wp.wctabtitle,
|
70 |
+
numitems: 14
|
71 |
},
|
72 |
"int-google-optimize": {
|
73 |
tabtext: gtm4wp.gotabtitle,
|
js/admin-tabcreator.js
CHANGED
@@ -12,12 +12,12 @@ jQuery( function() {
|
|
12 |
if ( adminsubtabsdata[ i ] ) {
|
13 |
var _subtabs = [];
|
14 |
var _startrow = 0;
|
15 |
-
|
16 |
for (var j in adminsubtabsdata[ i ] ) {
|
17 |
_subtabs.push( '<a href="#" data-formtableid="' + i + '" data-startrow="' + _startrow + '" data-endrow="' + (_startrow + adminsubtabsdata[ i ][ j ].numitems) + '">' + adminsubtabsdata[ i ][ j ].tabtext + '</a>' );
|
18 |
_startrow += adminsubtabsdata[ i ][ j ].numitems;
|
19 |
}
|
20 |
-
|
21 |
if ( _subtabs.length > 0 ) {
|
22 |
adminsubtabs.push( '<ul class="adminsubtabs" id="adminsubtabs' + i + '"><li>' + _subtabs.join('</li><li>') + '</li></ul>' );
|
23 |
}
|
12 |
if ( adminsubtabsdata[ i ] ) {
|
13 |
var _subtabs = [];
|
14 |
var _startrow = 0;
|
15 |
+
|
16 |
for (var j in adminsubtabsdata[ i ] ) {
|
17 |
_subtabs.push( '<a href="#" data-formtableid="' + i + '" data-startrow="' + _startrow + '" data-endrow="' + (_startrow + adminsubtabsdata[ i ][ j ].numitems) + '">' + adminsubtabsdata[ i ][ j ].tabtext + '</a>' );
|
18 |
_startrow += adminsubtabsdata[ i ][ j ].numitems;
|
19 |
}
|
20 |
+
|
21 |
if ( _subtabs.length > 0 ) {
|
22 |
adminsubtabs.push( '<ul class="adminsubtabs" id="adminsubtabs' + i + '"><li>' + _subtabs.join('</li><li>') + '</li></ul>' );
|
23 |
}
|
js/gtm4wp-soundcloud.js
CHANGED
@@ -4,10 +4,10 @@ var gtm4wp_soundclound_percentage_tracking_marks = {};
|
|
4 |
jQuery(function() {
|
5 |
// jQuery( '[id^="soundcloudplayer_"]' ).each(function() {
|
6 |
jQuery( 'iframe[src*="soundcloud.com"]' ).each(function() {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
widget.bind( SC.Widget.Events.READY, function() {
|
13 |
widget.getCurrentSound(function( soundData ) {
|
@@ -35,7 +35,7 @@ jQuery(function() {
|
|
35 |
}); // end of api call getDuration
|
36 |
|
37 |
widget.bind( SC.Widget.Events.PLAY_PROGRESS, function( eventData ) {
|
38 |
-
|
39 |
});
|
40 |
|
41 |
widget.bind( SC.Widget.Events.PLAY, function( eventData ) {
|
4 |
jQuery(function() {
|
5 |
// jQuery( '[id^="soundcloudplayer_"]' ).each(function() {
|
6 |
jQuery( 'iframe[src*="soundcloud.com"]' ).each(function() {
|
7 |
+
var iframe = this,
|
8 |
+
widget = SC.Widget( this ),
|
9 |
+
jqframe = jQuery( iframe ),
|
10 |
+
sound = {};
|
11 |
|
12 |
widget.bind( SC.Widget.Events.READY, function() {
|
13 |
widget.getCurrentSound(function( soundData ) {
|
35 |
}); // end of api call getDuration
|
36 |
|
37 |
widget.bind( SC.Widget.Events.PLAY_PROGRESS, function( eventData ) {
|
38 |
+
gtm4wp_onSoundCloudPercentageChange( eventData );
|
39 |
});
|
40 |
|
41 |
widget.bind( SC.Widget.Events.PLAY, function( eventData ) {
|
js/gtm4wp-vimeo-froogaloop.js
CHANGED
@@ -34,7 +34,7 @@ jQuery(function() {
|
|
34 |
}); // end of api call getDuration
|
35 |
|
36 |
vimeoapi.addEvent( 'playProgress', function( value, player_id ) {
|
37 |
-
|
38 |
});
|
39 |
|
40 |
vimeoapi.addEvent( 'play', function( player_id ) {
|
34 |
}); // end of api call getDuration
|
35 |
|
36 |
vimeoapi.addEvent( 'playProgress', function( value, player_id ) {
|
37 |
+
gtm4wp_onVimeoPercentageChange( value );
|
38 |
});
|
39 |
|
40 |
vimeoapi.addEvent( 'play', function( player_id ) {
|
js/gtm4wp-woocommerce-enhanced.js
CHANGED
@@ -12,6 +12,16 @@ function gtm4wp_handle_cart_qty_change() {
|
|
12 |
|
13 |
if ( _original_value != _current_value ) {
|
14 |
var productdata = jQuery( this ).closest( '.cart_item' ).find( '.remove' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
if ( _original_value < _current_value ) {
|
17 |
window[ gtm4wp_datalayer_name ].push({
|
@@ -22,10 +32,11 @@ function gtm4wp_handle_cart_qty_change() {
|
|
22 |
'products': [{
|
23 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
24 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
25 |
-
'price':
|
26 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
27 |
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
28 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
|
|
29 |
'quantity': _current_value - _original_value
|
30 |
}]
|
31 |
}
|
@@ -40,10 +51,11 @@ function gtm4wp_handle_cart_qty_change() {
|
|
40 |
'products': [{
|
41 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
42 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
43 |
-
'price':
|
44 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
45 |
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
46 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
|
|
47 |
'quantity': _original_value - _current_value
|
48 |
}]
|
49 |
}
|
@@ -61,18 +73,29 @@ jQuery(function() {
|
|
61 |
// track impressions of products in product lists
|
62 |
if ( jQuery( '.gtm4wp_productdata,.widget-product-item' ).length > 0 ) {
|
63 |
var products = [];
|
64 |
-
var productdata;
|
65 |
jQuery( '.gtm4wp_productdata,.widget-product-item' ).each( function() {
|
66 |
-
|
67 |
productdata = jQuery( this );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
products.push({
|
69 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
70 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
71 |
-
'price':
|
72 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
73 |
'position': productdata.data( 'gtm4wp_product_listposition' ),
|
74 |
'list': productdata.data( 'gtm4wp_productlist_name' ),
|
75 |
-
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' )
|
|
|
76 |
});
|
77 |
|
78 |
});
|
@@ -118,6 +141,16 @@ jQuery(function() {
|
|
118 |
// track add to cart events for simple products in product lists
|
119 |
jQuery( document ).on( 'click', '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)', function() {
|
120 |
var productdata = jQuery( this ).closest( '.product' ).find( '.gtm4wp_productdata' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
window[ gtm4wp_datalayer_name ].push({
|
123 |
'event': 'gtm4wp.addProductToCartEEC',
|
@@ -127,9 +160,10 @@ jQuery(function() {
|
|
127 |
'products': [{
|
128 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
129 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
130 |
-
'price':
|
131 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
132 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
|
|
133 |
'quantity': 1
|
134 |
}]
|
135 |
}
|
@@ -148,9 +182,12 @@ jQuery(function() {
|
|
148 |
var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val();
|
149 |
var _product_currency = jQuery( '[name=gtm4wp_currency]', _product_form ).val();
|
150 |
var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val();
|
|
|
151 |
|
152 |
if ( _product_var_id.length > 0 ) {
|
153 |
if ( gtm4wp_last_selected_product_variation ) {
|
|
|
|
|
154 |
window[ gtm4wp_datalayer_name ].push({
|
155 |
'event': 'gtm4wp.addProductToCartEEC',
|
156 |
'ecommerce': {
|
@@ -161,43 +198,6 @@ jQuery(function() {
|
|
161 |
}
|
162 |
});
|
163 |
}
|
164 |
-
/*
|
165 |
-
_product_var_id_val = _product_var_id.val();
|
166 |
-
_product_form_variations = _product_form.data( 'product_variations' );
|
167 |
-
|
168 |
-
_product_form_variations.forEach( function( product_var ) {
|
169 |
-
if ( product_var.variation_id == _product_var_id_val ) {
|
170 |
-
_product_var_sku = product_var.sku;
|
171 |
-
if ( ! _product_var_sku ) {
|
172 |
-
_product_var_sku = _product_var_id_val;
|
173 |
-
}
|
174 |
-
|
175 |
-
var _tmp = [];
|
176 |
-
for( var attrib_key in product_var.attributes ) {
|
177 |
-
_tmp.push( product_var.attributes[ attrib_key ] );
|
178 |
-
}
|
179 |
-
|
180 |
-
window[ gtm4wp_datalayer_name ].push({
|
181 |
-
'event': 'gtm4wp.addProductToCartEEC',
|
182 |
-
'ecommerce': {
|
183 |
-
'currencyCode': _product_currency,
|
184 |
-
'add': {
|
185 |
-
'products': [{
|
186 |
-
'id': gtm4wp_use_sku_instead ? _product_var_sku : _product_var_id_val,
|
187 |
-
'name': _product_name,
|
188 |
-
'price': product_var.display_price,
|
189 |
-
'category': _product_category,
|
190 |
-
'variant': _tmp.join(','),
|
191 |
-
'quantity': jQuery( 'form.cart:first input[name=quantity]' ).val(),
|
192 |
-
'stocklevel': _product_stocklevel
|
193 |
-
}]
|
194 |
-
}
|
195 |
-
}
|
196 |
-
});
|
197 |
-
|
198 |
-
}
|
199 |
-
});
|
200 |
-
*/
|
201 |
} else {
|
202 |
window[ gtm4wp_datalayer_name ].push({
|
203 |
'event': 'gtm4wp.addProductToCartEEC',
|
@@ -210,7 +210,8 @@ jQuery(function() {
|
|
210 |
'price': _product_price,
|
211 |
'category': _product_category,
|
212 |
'quantity': jQuery( 'form.cart:first input[name=quantity]' ).val(),
|
213 |
-
'stocklevel': _product_stocklevel
|
|
|
214 |
}]
|
215 |
}
|
216 |
}
|
@@ -252,6 +253,7 @@ jQuery(function() {
|
|
252 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
253 |
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
254 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
|
|
255 |
'quantity': qty
|
256 |
}]
|
257 |
}
|
@@ -318,6 +320,7 @@ jQuery(function() {
|
|
318 |
'price': productdata.data( 'gtm4wp_product_price' ),
|
319 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
320 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
|
|
321 |
'position': productdata.data( 'gtm4wp_product_listposition' )
|
322 |
}]
|
323 |
}
|
@@ -354,6 +357,7 @@ jQuery(function() {
|
|
354 |
var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val();
|
355 |
var _product_currency = jQuery( '[name=gtm4wp_currency]', _product_form ).val();
|
356 |
var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val();
|
|
|
357 |
|
358 |
var current_product_detail_data = {
|
359 |
name: _product_name,
|
@@ -361,6 +365,7 @@ jQuery(function() {
|
|
361 |
price: 0,
|
362 |
category: _product_category,
|
363 |
stocklevel: _product_stocklevel,
|
|
|
364 |
variant: ''
|
365 |
};
|
366 |
|
@@ -398,12 +403,14 @@ jQuery(function() {
|
|
398 |
|
399 |
// initiate codes in WooCommere Quick View
|
400 |
jQuery( document ).ajaxSuccess( function( event, xhr, settings ) {
|
401 |
-
if
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
|
|
|
|
407 |
}
|
408 |
});
|
409 |
|
@@ -424,7 +431,7 @@ jQuery(function() {
|
|
424 |
window.gtm4wp_checkout_products = window.gtm4wp_checkout_products || [];
|
425 |
var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here
|
426 |
|
427 |
-
jQuery( document ).on( 'blur', 'input[name^=shipping_]:not(input[name
|
428 |
// do not report checkout step if already reported
|
429 |
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping' ) > -1 ) {
|
430 |
return;
|
@@ -450,7 +457,7 @@ jQuery(function() {
|
|
450 |
gtm4wp_checkout_step_fired.push( 'shipping' );
|
451 |
});
|
452 |
|
453 |
-
jQuery( document ).on( 'change', 'input[name
|
454 |
// do not report checkout step if already reported
|
455 |
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) > -1 ) {
|
456 |
return;
|
@@ -506,7 +513,7 @@ jQuery(function() {
|
|
506 |
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) {
|
507 |
// shipping methods are not visible if only one is available
|
508 |
// and if the user has already a pre-selected method, no click event will fire to report the checkout step
|
509 |
-
jQuery( 'input[name
|
510 |
|
511 |
gtm4wp_checkout_step_fired.push( 'shipping_method' );
|
512 |
}
|
@@ -550,7 +557,7 @@ jQuery(function() {
|
|
550 |
});
|
551 |
}
|
552 |
|
553 |
-
// codes for
|
554 |
if ( window.gtm4wp_remarketing&& !is_cart && !is_checkout ) {
|
555 |
if ( jQuery( '.gtm4wp_productdata' ).length > 0 ) {
|
556 |
for( var i=0; i<window[ gtm4wp_datalayer_name ].length; i++ ) {
|
@@ -577,4 +584,4 @@ jQuery(function() {
|
|
577 |
});
|
578 |
}
|
579 |
}
|
580 |
-
});
|
12 |
|
13 |
if ( _original_value != _current_value ) {
|
14 |
var productdata = jQuery( this ).closest( '.cart_item' ).find( '.remove' );
|
15 |
+
var productprice = productdata.data( 'gtm4wp_product_price' );
|
16 |
+
|
17 |
+
if ( typeof productprice == "string" ) {
|
18 |
+
productprice = parseFloat( productprice );
|
19 |
+
if ( isNaN( productprice ) ) {
|
20 |
+
productprice = 0;
|
21 |
+
}
|
22 |
+
} else if ( typeof productprice != "number" ) {
|
23 |
+
productprice = 0;
|
24 |
+
}
|
25 |
|
26 |
if ( _original_value < _current_value ) {
|
27 |
window[ gtm4wp_datalayer_name ].push({
|
32 |
'products': [{
|
33 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
34 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
35 |
+
'price': productprice.toFixed(2),
|
36 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
37 |
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
38 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
39 |
+
'brand': productdata.data( 'gtm4wp_product_brand' ),
|
40 |
'quantity': _current_value - _original_value
|
41 |
}]
|
42 |
}
|
51 |
'products': [{
|
52 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
53 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
54 |
+
'price': productprice.toFixed(2),
|
55 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
56 |
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
57 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
58 |
+
'brand': productdata.data( 'gtm4wp_product_brand' ),
|
59 |
'quantity': _original_value - _current_value
|
60 |
}]
|
61 |
}
|
73 |
// track impressions of products in product lists
|
74 |
if ( jQuery( '.gtm4wp_productdata,.widget-product-item' ).length > 0 ) {
|
75 |
var products = [];
|
76 |
+
var productdata, productprice=0;
|
77 |
jQuery( '.gtm4wp_productdata,.widget-product-item' ).each( function() {
|
|
|
78 |
productdata = jQuery( this );
|
79 |
+
productprice = productdata.data( 'gtm4wp_product_price' );
|
80 |
+
|
81 |
+
if ( typeof productprice == "string" ) {
|
82 |
+
productprice = parseFloat( productprice );
|
83 |
+
if ( isNaN( productprice ) ) {
|
84 |
+
productprice = 0;
|
85 |
+
}
|
86 |
+
} else if ( typeof productprice != "number" ) {
|
87 |
+
productprice = 0;
|
88 |
+
}
|
89 |
+
|
90 |
products.push({
|
91 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
92 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
93 |
+
'price': productprice.toFixed(2),
|
94 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
95 |
'position': productdata.data( 'gtm4wp_product_listposition' ),
|
96 |
'list': productdata.data( 'gtm4wp_productlist_name' ),
|
97 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
98 |
+
'brand': productdata.data( 'gtm4wp_product_brand' )
|
99 |
});
|
100 |
|
101 |
});
|
141 |
// track add to cart events for simple products in product lists
|
142 |
jQuery( document ).on( 'click', '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)', function() {
|
143 |
var productdata = jQuery( this ).closest( '.product' ).find( '.gtm4wp_productdata' );
|
144 |
+
var productprice = productdata.data( 'gtm4wp_product_price' );
|
145 |
+
|
146 |
+
if ( typeof productprice == "string" ) {
|
147 |
+
productprice = parseFloat( productprice );
|
148 |
+
if ( isNaN( productprice ) ) {
|
149 |
+
productprice = 0;
|
150 |
+
}
|
151 |
+
} else if ( typeof productprice != "number" ) {
|
152 |
+
productprice = 0;
|
153 |
+
}
|
154 |
|
155 |
window[ gtm4wp_datalayer_name ].push({
|
156 |
'event': 'gtm4wp.addProductToCartEEC',
|
160 |
'products': [{
|
161 |
'name': productdata.data( 'gtm4wp_product_name' ),
|
162 |
'id': productdata.data( 'gtm4wp_product_id' ),
|
163 |
+
'price': productprice.toFixed(2),
|
164 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
165 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
166 |
+
'brand': productdata.data( 'gtm4wp_product_brand' ),
|
167 |
'quantity': 1
|
168 |
}]
|
169 |
}
|
182 |
var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val();
|
183 |
var _product_currency = jQuery( '[name=gtm4wp_currency]', _product_form ).val();
|
184 |
var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val();
|
185 |
+
var _product_brand = jQuery( '[name=gtm4wp_brand]', _product_form ).val();
|
186 |
|
187 |
if ( _product_var_id.length > 0 ) {
|
188 |
if ( gtm4wp_last_selected_product_variation ) {
|
189 |
+
gtm4wp_last_selected_product_variation.quantity = jQuery( 'form.cart:first input[name=quantity]' ).val();
|
190 |
+
|
191 |
window[ gtm4wp_datalayer_name ].push({
|
192 |
'event': 'gtm4wp.addProductToCartEEC',
|
193 |
'ecommerce': {
|
198 |
}
|
199 |
});
|
200 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
} else {
|
202 |
window[ gtm4wp_datalayer_name ].push({
|
203 |
'event': 'gtm4wp.addProductToCartEEC',
|
210 |
'price': _product_price,
|
211 |
'category': _product_category,
|
212 |
'quantity': jQuery( 'form.cart:first input[name=quantity]' ).val(),
|
213 |
+
'stocklevel': _product_stocklevel,
|
214 |
+
'brand': _product_brand
|
215 |
}]
|
216 |
}
|
217 |
}
|
253 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
254 |
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
255 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
256 |
+
'brand': productdata.data( 'gtm4wp_product_brand' ),
|
257 |
'quantity': qty
|
258 |
}]
|
259 |
}
|
320 |
'price': productdata.data( 'gtm4wp_product_price' ),
|
321 |
'category': productdata.data( 'gtm4wp_product_cat' ),
|
322 |
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
323 |
+
'brand': productdata.data( 'gtm4wp_product_brand' ),
|
324 |
'position': productdata.data( 'gtm4wp_product_listposition' )
|
325 |
}]
|
326 |
}
|
357 |
var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val();
|
358 |
var _product_currency = jQuery( '[name=gtm4wp_currency]', _product_form ).val();
|
359 |
var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val();
|
360 |
+
var _product_brand = jQuery( '[name=gtm4wp_brand]', _product_form ).val();
|
361 |
|
362 |
var current_product_detail_data = {
|
363 |
name: _product_name,
|
365 |
price: 0,
|
366 |
category: _product_category,
|
367 |
stocklevel: _product_stocklevel,
|
368 |
+
brand: _product_brand,
|
369 |
variant: ''
|
370 |
};
|
371 |
|
403 |
|
404 |
// initiate codes in WooCommere Quick View
|
405 |
jQuery( document ).ajaxSuccess( function( event, xhr, settings ) {
|
406 |
+
if(typeof settings !== 'undefined') {
|
407 |
+
if (settings.url.indexOf( 'wc-api=WC_Quick_View' ) > -1 ) {
|
408 |
+
setTimeout( function() {
|
409 |
+
jQuery( ".woocommerce.quick-view" ).parent().find( "script" ).each( function(i) {
|
410 |
+
eval( jQuery( this ).text() );
|
411 |
+
});
|
412 |
+
}, 500);
|
413 |
+
}
|
414 |
}
|
415 |
});
|
416 |
|
431 |
window.gtm4wp_checkout_products = window.gtm4wp_checkout_products || [];
|
432 |
var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here
|
433 |
|
434 |
+
jQuery( document ).on( 'blur', 'input[name^=shipping_]:not(input[name^=shipping_method])', function() {
|
435 |
// do not report checkout step if already reported
|
436 |
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping' ) > -1 ) {
|
437 |
return;
|
457 |
gtm4wp_checkout_step_fired.push( 'shipping' );
|
458 |
});
|
459 |
|
460 |
+
jQuery( document ).on( 'change', 'input[name^=shipping_method]', function() {
|
461 |
// do not report checkout step if already reported
|
462 |
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) > -1 ) {
|
463 |
return;
|
513 |
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) {
|
514 |
// shipping methods are not visible if only one is available
|
515 |
// and if the user has already a pre-selected method, no click event will fire to report the checkout step
|
516 |
+
jQuery( 'input[name^=shipping_method]:checked' ).trigger( 'click' );
|
517 |
|
518 |
gtm4wp_checkout_step_fired.push( 'shipping_method' );
|
519 |
}
|
557 |
});
|
558 |
}
|
559 |
|
560 |
+
// codes for Google Ads dynamic remarketing
|
561 |
if ( window.gtm4wp_remarketing&& !is_cart && !is_checkout ) {
|
562 |
if ( jQuery( '.gtm4wp_productdata' ).length > 0 ) {
|
563 |
for( var i=0; i<window[ gtm4wp_datalayer_name ].length; i++ ) {
|
584 |
});
|
585 |
}
|
586 |
}
|
587 |
+
});
|
public/frontend.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
<?php
|
2 |
-
define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER',
|
3 |
define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtm4wp_compile_remarkering' );
|
4 |
-
define( 'GTM4WP_WPFILTER_AFTER_DATALAYER',
|
5 |
-
define( 'GTM4WP_WPFILTER_GETTHEGTMTAG',
|
6 |
-
define( 'GTM4WP_WPACTION_ADDGLOBALVARS',
|
7 |
|
8 |
-
$GLOBALS[
|
9 |
|
10 |
// check for empty is needed to prevent error in WP CLI
|
11 |
// bugfix by Patrick Holberg Hesselberg
|
12 |
-
if ( empty($GLOBALS[
|
13 |
-
$GLOBALS[
|
14 |
} else {
|
15 |
-
$GLOBALS[
|
16 |
}
|
17 |
|
18 |
// Setting Global Variable to Store JSON based Datalayer for Intergrations
|
19 |
-
$GLOBALS[
|
20 |
-
$GLOBALS[
|
21 |
|
22 |
// Moving include to top due to hierarchy of includes
|
23 |
-
if ( isset( $GLOBALS[
|
24 |
-
require_once
|
25 |
}
|
26 |
-
if ( !function_exists('gtm4wp_amp_running') ) {
|
27 |
-
function gtm4wp_amp_running(){
|
28 |
return false;
|
29 |
}
|
30 |
}
|
@@ -35,18 +35,18 @@ if ( !function_exists('gtm4wp_amp_running') ) {
|
|
35 |
* @author Vincent Koc <https://github.com/koconder/>
|
36 |
* @return mixed Returs object or string false
|
37 |
*/
|
38 |
-
function gtm4wp_escjs_boolean($obj){
|
39 |
-
if(empty($obj) || is_null($obj) ||
|
40 |
return 'false';
|
41 |
-
}else{
|
42 |
return $obj;
|
43 |
}
|
44 |
}
|
45 |
|
46 |
-
function gtm4wp_is_assoc($arr) {
|
47 |
// borrowed from
|
48 |
// http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential
|
49 |
-
return array_keys($arr) !== range(0, count($arr) - 1);
|
50 |
}
|
51 |
|
52 |
/**
|
@@ -56,23 +56,23 @@ function gtm4wp_is_assoc($arr) {
|
|
56 |
* Code improved by Thomas Geiger
|
57 |
*/
|
58 |
function gtm4wp_ip_is_private( $ip ) {
|
59 |
-
$int_ip = ip2long($ip);
|
60 |
-
if ( !empty($ip) && $int_ip
|
61 |
-
$private_ips = array
|
62 |
-
array('0.0.0.0',
|
63 |
-
array('10.0.0.0',
|
64 |
-
array('127.0.0.0',
|
65 |
-
array('169.254.0.0',
|
66 |
-
array('172.16.0.0',
|
67 |
-
array('192.0.2.0',
|
68 |
-
array('192.168.0.0',
|
69 |
-
array('255.255.255.0','255.255.255.255')
|
70 |
);
|
71 |
|
72 |
-
foreach ($private_ips as $private_ip) {
|
73 |
$min_int_ip = ip2long( $private_ip[0] );
|
74 |
$max_int_ip = ip2long( $private_ip[1] );
|
75 |
-
if ( ($int_ip >= $
|
76 |
return true;
|
77 |
}
|
78 |
}
|
@@ -90,37 +90,37 @@ function gtm4wp_ip_is_private( $ip ) {
|
|
90 |
* Code improved by Thomas Geiger
|
91 |
*/
|
92 |
function gtm4wp_get_user_ip() {
|
93 |
-
if ( !empty($_SERVER[
|
94 |
-
return $_SERVER[
|
95 |
}
|
96 |
|
97 |
-
if ( !empty($_SERVER[
|
98 |
-
foreach (explode(
|
99 |
-
if ( !gtm4wp_ip_is_private(trim($ip)) ) {
|
100 |
return $ip;
|
101 |
}
|
102 |
}
|
103 |
}
|
104 |
|
105 |
-
if ( !empty($_SERVER[
|
106 |
-
return $_SERVER[
|
107 |
-
} elseif ( !empty($_SERVER[
|
108 |
-
return $_SERVER[
|
109 |
-
} elseif ( !empty($_SERVER[
|
110 |
-
return $_SERVER[
|
111 |
-
} elseif ( !empty($_SERVER[
|
112 |
-
return $_SERVER[
|
113 |
} else {
|
114 |
-
return $_SERVER[
|
115 |
}
|
116 |
}
|
117 |
|
118 |
-
if ( !function_exists(
|
119 |
function getallheaders() {
|
120 |
$headers = array();
|
121 |
foreach ( $_SERVER as $name => $value ) {
|
122 |
-
if ( substr($name, 0, 5) ==
|
123 |
-
$headers[ str_replace(' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
|
124 |
}
|
125 |
}
|
126 |
|
@@ -132,30 +132,30 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
132 |
global $wp_query, $gtm4wp_options;
|
133 |
|
134 |
if ( $gtm4wp_options[ GTM4WP_OPTION_DONOTTRACK ] ) {
|
135 |
-
if ( !empty( $_SERVER['HTTP_DNT'] ) ) {
|
136 |
-
$dataLayer[
|
137 |
} else {
|
138 |
-
$dataLayer[
|
139 |
}
|
140 |
}
|
141 |
|
142 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_SITEID ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_SITENAME ] ) {
|
143 |
-
$dataLayer[
|
144 |
-
$dataLayer[
|
145 |
|
146 |
if ( function_exists( 'get_blog_details' ) ) {
|
147 |
$gtm4wp_blogdetails = get_blog_details();
|
148 |
|
149 |
-
$dataLayer[
|
150 |
-
$dataLayer[
|
151 |
}
|
152 |
}
|
153 |
|
154 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_LOGGEDIN ] ) {
|
155 |
if ( is_user_logged_in() ) {
|
156 |
-
$dataLayer[
|
157 |
} else {
|
158 |
-
$dataLayer[
|
159 |
}
|
160 |
}
|
161 |
|
@@ -163,49 +163,49 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
163 |
$current_user = wp_get_current_user();
|
164 |
|
165 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERROLE ] ) {
|
166 |
-
$dataLayer[
|
167 |
}
|
168 |
|
169 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USEREMAIL ] ) {
|
170 |
-
$dataLayer[
|
171 |
}
|
172 |
|
173 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERREGDATE ] ) {
|
174 |
-
$dataLayer[
|
175 |
}
|
176 |
|
177 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERNAME ] ) {
|
178 |
-
$dataLayer[
|
179 |
}
|
180 |
}
|
181 |
|
182 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERID ] ) {
|
183 |
$_gtm4wp_userid = get_current_user_id();
|
184 |
if ( $_gtm4wp_userid > 0 ) {
|
185 |
-
$dataLayer[
|
186 |
}
|
187 |
}
|
188 |
|
189 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_VISITOR_IP ] ) {
|
190 |
-
$dataLayer[
|
191 |
}
|
192 |
|
193 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
|
194 |
-
$dataLayer[
|
195 |
}
|
196 |
|
197 |
if ( is_singular() ) {
|
198 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
199 |
-
$dataLayer[
|
200 |
-
$dataLayer[
|
201 |
}
|
202 |
|
203 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_CATEGORIES ] ) {
|
204 |
$_post_cats = get_the_category();
|
205 |
if ( $_post_cats ) {
|
206 |
-
$dataLayer[
|
207 |
-
foreach( $_post_cats as $_one_cat ) {
|
208 |
-
$dataLayer[
|
209 |
}
|
210 |
}
|
211 |
}
|
@@ -213,172 +213,188 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
213 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_TAGS ] ) {
|
214 |
$_post_tags = get_the_tags();
|
215 |
if ( $_post_tags ) {
|
216 |
-
$dataLayer[
|
217 |
-
foreach( $_post_tags as $_one_tag ) {
|
218 |
-
$dataLayer[
|
219 |
}
|
220 |
}
|
221 |
}
|
222 |
|
223 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) {
|
224 |
-
$postuser = get_userdata( $GLOBALS[
|
225 |
|
226 |
if ( false !== $postuser ) {
|
227 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] ) {
|
228 |
-
|
229 |
}
|
230 |
|
231 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) {
|
232 |
-
$dataLayer[
|
233 |
}
|
234 |
}
|
235 |
}
|
236 |
|
237 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
238 |
-
$dataLayer[
|
239 |
-
$dataLayer[
|
240 |
-
$dataLayer[
|
241 |
-
$dataLayer[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
}
|
244 |
|
245 |
if ( is_archive() || is_post_type_archive() ) {
|
246 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
247 |
-
$dataLayer[
|
248 |
|
249 |
if ( is_category() ) {
|
250 |
-
$dataLayer[
|
251 |
-
}
|
252 |
-
$dataLayer[
|
253 |
-
}
|
254 |
-
$dataLayer[
|
255 |
-
}
|
256 |
-
$dataLayer[
|
257 |
-
}
|
258 |
-
$dataLayer[
|
259 |
|
260 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
261 |
-
$dataLayer[
|
262 |
}
|
263 |
-
}
|
264 |
-
$dataLayer[
|
265 |
|
266 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
267 |
-
$dataLayer[
|
268 |
-
$dataLayer[
|
269 |
}
|
270 |
-
}
|
271 |
-
$dataLayer[
|
272 |
|
273 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
274 |
-
$dataLayer[
|
275 |
-
$dataLayer[
|
276 |
-
$dataLayer[
|
277 |
-
$dataLayer[
|
278 |
}
|
279 |
-
}
|
280 |
-
$dataLayer[
|
281 |
-
}
|
282 |
-
$dataLayer[
|
283 |
|
284 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
285 |
-
$dataLayer[
|
286 |
-
$dataLayer[
|
287 |
-
$dataLayer[
|
288 |
-
$dataLayer[
|
289 |
}
|
290 |
}
|
291 |
}
|
292 |
|
293 |
if ( ( is_tax() || is_category() ) && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_CATEGORIES ] ) {
|
294 |
-
$_post_cats
|
295 |
-
$dataLayer[
|
296 |
-
foreach( $_post_cats as $_one_cat ) {
|
297 |
-
$dataLayer[
|
298 |
}
|
299 |
}
|
300 |
|
301 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] ) && ( is_author() ) ) {
|
302 |
global $authordata;
|
303 |
-
$dataLayer[
|
304 |
}
|
305 |
|
306 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) && ( is_author() ) ) {
|
307 |
-
$dataLayer[
|
308 |
}
|
309 |
}
|
310 |
|
311 |
if ( is_search() ) {
|
312 |
-
$dataLayer[
|
313 |
-
$dataLayer[
|
314 |
-
if ( !empty($_SERVER[
|
315 |
-
$referer_url_parts = explode(
|
316 |
if ( count( $referer_url_parts ) > 1 ) {
|
317 |
-
$dataLayer[
|
318 |
} else {
|
319 |
-
$dataLayer[
|
320 |
}
|
321 |
}
|
322 |
-
$dataLayer[
|
323 |
}
|
324 |
|
325 |
if ( is_front_page() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
326 |
-
$dataLayer[
|
327 |
}
|
328 |
|
329 |
-
if ( !is_front_page() && is_home() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
330 |
-
$dataLayer[
|
331 |
}
|
332 |
|
333 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
334 |
-
spl_autoload_register(
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
|
|
338 |
}
|
339 |
-
|
340 |
|
341 |
-
require_once
|
342 |
|
343 |
$gtp4wp_headers = getallheaders();
|
344 |
if ( ( false === $gtp4wp_headers ) && isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
345 |
$gtp4wp_headers = $_SERVER['HTTP_USER_AGENT'];
|
346 |
}
|
347 |
if ( false !== $gtp4wp_headers ) {
|
348 |
-
$detected = new WhichBrowser\Parser($gtp4wp_headers);
|
349 |
|
350 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] ) {
|
351 |
-
$dataLayer[
|
352 |
-
$dataLayer[
|
353 |
|
354 |
-
$dataLayer[
|
355 |
-
$dataLayer[
|
356 |
}
|
357 |
|
358 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] ) {
|
359 |
-
$dataLayer[
|
360 |
-
$dataLayer[
|
361 |
}
|
362 |
|
363 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
364 |
-
$dataLayer[
|
365 |
-
$dataLayer[
|
366 |
-
$dataLayer[
|
367 |
}
|
368 |
}
|
369 |
}
|
370 |
|
371 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTCOUNT ] ) {
|
372 |
-
$dataLayer[
|
373 |
-
$dataLayer[
|
374 |
}
|
375 |
|
376 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTID ] && is_singular() === true) {
|
377 |
-
$dataLayer[
|
378 |
}
|
379 |
|
380 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTFORMAT ] && is_singular() === true) {
|
381 |
-
$dataLayer[
|
382 |
}
|
383 |
|
384 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] > 0 ) {
|
@@ -386,158 +402,162 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
386 |
|
387 |
// IDs from https://developers.google.com/tag-manager/devguide#security
|
388 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ADADVISOR ] ) {
|
389 |
-
$_gtmrestrictlistitems[] =
|
390 |
}
|
391 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ADROLL ] ) {
|
392 |
-
$_gtmrestrictlistitems[] =
|
393 |
}
|
394 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_AWCONV ] ) {
|
395 |
-
$_gtmrestrictlistitems[] =
|
396 |
}
|
397 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_AWREMARKET ] ) {
|
398 |
-
$_gtmrestrictlistitems[] =
|
399 |
}
|
400 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_BIZO ] ) {
|
401 |
-
$_gtmrestrictlistitems[] =
|
402 |
}
|
403 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CLICKTALE ] ) {
|
404 |
-
$_gtmrestrictlistitems[] =
|
405 |
}
|
406 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_COMSCORE ] ) {
|
407 |
-
$_gtmrestrictlistitems[] =
|
408 |
}
|
409 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CUSTOMHTML ] ) {
|
410 |
-
$_gtmrestrictlistitems[] =
|
411 |
}
|
412 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CUSTOMIMG ] ) {
|
413 |
-
$_gtmrestrictlistitems[] =
|
414 |
}
|
415 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT ] ) {
|
416 |
-
$_gtmrestrictlistitems[] =
|
417 |
}
|
418 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_DBLCLKSALES ] ) {
|
419 |
-
$_gtmrestrictlistitems[] =
|
420 |
}
|
421 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_GACLASSIC ] ) {
|
422 |
-
$_gtmrestrictlistitems[] =
|
423 |
}
|
424 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MARIN ] ) {
|
425 |
-
$_gtmrestrictlistitems[] =
|
426 |
}
|
427 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME ] ) {
|
428 |
-
$_gtmrestrictlistitems[] =
|
429 |
}
|
430 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MPLEXROI ] ) {
|
431 |
-
$_gtmrestrictlistitems[] =
|
432 |
}
|
433 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MEDIA6DEG ] ) {
|
434 |
-
$_gtmrestrictlistitems[] =
|
435 |
}
|
436 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_TURNCONV ] ) {
|
437 |
-
$_gtmrestrictlistitems[] =
|
438 |
}
|
439 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_TURNDATA ] ) {
|
440 |
-
$_gtmrestrictlistitems[] =
|
441 |
}
|
442 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_UA ] ) {
|
443 |
-
$_gtmrestrictlistitems[] =
|
444 |
}
|
445 |
|
446 |
$_gtmwhitelist = array();
|
447 |
$_gtmblacklist = array();
|
448 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 1 ) {
|
449 |
-
$_gtmblacklist = array_merge($_gtmblacklist, $_gtmrestrictlistitems);
|
450 |
} else {
|
451 |
-
$_gtmwhitelist = array_merge($_gtmwhitelist, $_gtmrestrictlistitems);
|
452 |
}
|
453 |
|
454 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT ] ) {
|
455 |
-
$_gtmwhitelist[] =
|
456 |
}
|
457 |
|
458 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS ] ) {
|
459 |
-
$_gtmwhitelist[] =
|
460 |
}
|
461 |
|
462 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT ] ) {
|
463 |
-
$_gtmwhitelist[] =
|
464 |
}
|
465 |
|
466 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE ] ) {
|
467 |
-
$_gtmwhitelist[] =
|
468 |
}
|
469 |
|
470 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME ] ) {
|
471 |
-
$_gtmwhitelist[] =
|
472 |
}
|
473 |
|
474 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR ] ) {
|
475 |
-
$_gtmwhitelist[] =
|
476 |
}
|
477 |
|
478 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR ] ) {
|
479 |
-
$_gtmwhitelist[] =
|
480 |
}
|
481 |
|
482 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM ] ) {
|
483 |
-
$_gtmwhitelist[] =
|
484 |
}
|
485 |
|
486 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER ] ) {
|
487 |
-
$_gtmwhitelist[] =
|
488 |
}
|
489 |
|
490 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_URL ] ) {
|
491 |
-
$_gtmwhitelist[] =
|
492 |
}
|
493 |
|
494 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT ] ) {
|
495 |
-
$_gtmwhitelist[] =
|
496 |
}
|
497 |
|
498 |
-
$dataLayer[
|
499 |
-
$dataLayer[
|
500 |
}
|
501 |
|
502 |
-
if ( $gtm4wp_options[
|
|
|
|
|
|
|
|
|
503 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
|
504 |
-
$dataLayer[
|
505 |
-
$dataLayer[
|
506 |
-
$dataLayer[
|
507 |
-
$dataLayer[
|
508 |
-
$dataLayer[
|
509 |
-
$dataLayer[
|
510 |
-
$dataLayer[
|
511 |
}
|
512 |
|
513 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
|
514 |
-
$dataLayer[
|
515 |
-
$dataLayer[
|
516 |
-
$dataLayer[
|
517 |
-
$dataLayer[
|
518 |
-
$dataLayer[
|
519 |
-
$dataLayer[
|
520 |
-
$dataLayer[
|
521 |
-
$dataLayer[
|
522 |
}
|
523 |
|
524 |
$client_ip = gtm4wp_get_user_ip();
|
525 |
|
526 |
-
if (
|
527 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
|
528 |
$weatherdata = get_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ) );
|
529 |
|
530 |
if ( false !== $weatherdata ) {
|
531 |
-
$dataLayer[
|
532 |
-
$dataLayer[
|
533 |
-
$dataLayer[
|
534 |
-
$dataLayer[
|
535 |
-
$dataLayer[
|
536 |
-
$dataLayer[
|
537 |
-
$dataLayer[
|
538 |
-
$dataLayer[
|
539 |
} else {
|
540 |
-
$dataLayer[
|
541 |
}
|
542 |
}
|
543 |
|
@@ -545,17 +565,17 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
545 |
$geodata = get_transient( 'gtm4wp-geodata-' . esc_attr( $client_ip ) );
|
546 |
|
547 |
if ( false !== $geodata ) {
|
548 |
-
$dataLayer[
|
549 |
|
550 |
if ( isset( $geodata->latitude ) ) {
|
551 |
-
$dataLayer[
|
552 |
-
$dataLayer[
|
553 |
-
$dataLayer[
|
554 |
-
$dataLayer[
|
555 |
-
$dataLayer[
|
556 |
-
$dataLayer[
|
557 |
-
$dataLayer[
|
558 |
-
$dataLayer[
|
559 |
}
|
560 |
}
|
561 |
}
|
@@ -575,8 +595,8 @@ function gtm4wp_wp_loaded() {
|
|
575 |
if ( false === $geodata ) {
|
576 |
$gtm4wp_geodata = @wp_remote_get( sprintf( 'http://api.ipstack.com/%s?access_key=%s&format=1', urlencode( $client_ip ), $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEOAPI ] ) );
|
577 |
|
578 |
-
if ( is_array( $gtm4wp_geodata ) && ( 200 == $gtm4wp_geodata[
|
579 |
-
$gtm4wp_geodata = @json_decode( $gtm4wp_geodata[
|
580 |
|
581 |
if ( is_object( $gtm4wp_geodata ) ) {
|
582 |
set_transient( 'gtm4wp-geodata-' . esc_attr( $client_ip ), $gtm4wp_geodata, 60 * 60 );
|
@@ -584,33 +604,33 @@ function gtm4wp_wp_loaded() {
|
|
584 |
$weatherdata = get_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ) );
|
585 |
if ( false === $weatherdata && isset( $gtm4wp_geodata->latitude ) ) {
|
586 |
|
587 |
-
$weatherdata = wp_remote_get( 'http://api.openweathermap.org/data/2.5/weather?appid=' . $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI ] . '&lat=' . $gtm4wp_geodata->latitude . '&lon=' . $gtm4wp_geodata->longitude . '&units=' . ($gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'metric' : 'imperial') );
|
588 |
|
589 |
-
if ( is_array( $weatherdata ) && ( 200 == $weatherdata[
|
590 |
-
$weatherdata = @json_decode( $weatherdata[
|
591 |
|
592 |
if ( is_object( $weatherdata ) ) {
|
593 |
set_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ), $weatherdata, 60 * 60 );
|
594 |
-
setcookie(
|
595 |
} else {
|
596 |
-
setcookie(
|
597 |
}
|
598 |
} else {
|
599 |
if ( is_wp_error( $weatherdata ) ) {
|
600 |
-
setcookie(
|
601 |
} else {
|
602 |
-
setcookie(
|
603 |
}
|
604 |
}
|
605 |
}
|
606 |
} else {
|
607 |
-
setcookie(
|
608 |
}
|
609 |
} else {
|
610 |
if ( is_wp_error( $gtm4wp_geodata ) ) {
|
611 |
-
setcookie(
|
612 |
} else {
|
613 |
-
setcookie(
|
614 |
}
|
615 |
}
|
616 |
}
|
@@ -627,16 +647,16 @@ function gtm4wp_get_the_gtm_tag() {
|
|
627 |
$gtm4wp_container_code_written = true;
|
628 |
}
|
629 |
|
630 |
-
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] !=
|
631 |
-
$_gtm_codes = explode(
|
632 |
|
633 |
-
if ( (
|
634 |
-
$_gtm_env =
|
635 |
} else {
|
636 |
$_gtm_env = '';
|
637 |
}
|
638 |
|
639 |
-
foreach( $_gtm_codes as $one_gtm_code ) {
|
640 |
$_gtm_tag .= '
|
641 |
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' . $one_gtm_code . $_gtm_env . '"
|
642 |
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>';
|
@@ -645,7 +665,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|
645 |
$_gtm_tag .= '
|
646 |
<!-- End Google Tag Manager (noscript) -->';
|
647 |
|
648 |
-
$_gtm_tag
|
649 |
$gtm4wp_container_code_written = true;
|
650 |
}
|
651 |
|
@@ -660,50 +680,50 @@ function gtm4wp_enqueue_scripts() {
|
|
660 |
global $gtm4wp_options, $gtp4wp_plugin_url;
|
661 |
|
662 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) {
|
663 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_OUTBOUND, false);
|
664 |
-
wp_enqueue_script(
|
665 |
}
|
666 |
|
667 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DOWNLOADS ] ) {
|
668 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_DOWNLOADS, false);
|
669 |
-
wp_enqueue_script(
|
670 |
}
|
671 |
|
672 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_EMAILCLICKS ] ) {
|
673 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_EMAILCLICKS, false);
|
674 |
-
wp_enqueue_script(
|
675 |
}
|
676 |
|
677 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WPCF7 ] ) {
|
678 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WPCF7, false);
|
679 |
-
wp_enqueue_script(
|
680 |
}
|
681 |
|
682 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_FORMMOVE ] ) {
|
683 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_FORMMOVE, false);
|
684 |
-
wp_enqueue_script(
|
685 |
}
|
686 |
|
687 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOCIAL ] ) {
|
688 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_SOCIAL, false);
|
689 |
-
wp_enqueue_script(
|
690 |
}
|
691 |
|
692 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_YOUTUBE ] ) {
|
693 |
-
require_once
|
694 |
}
|
695 |
|
696 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_VIMEO ] ) {
|
697 |
-
require_once
|
698 |
}
|
699 |
|
700 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOUNDCLOUD ] ) {
|
701 |
-
require_once
|
702 |
}
|
703 |
|
704 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
705 |
-
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_SCROLLER_ENABLED, false);
|
706 |
-
wp_enqueue_script(
|
707 |
}
|
708 |
}
|
709 |
|
@@ -724,8 +744,8 @@ function gtm4wp_wp_body_open() {
|
|
724 |
}
|
725 |
|
726 |
function gtm4wp_filter_visitor_keys( $dataLayer ) {
|
727 |
-
foreach( $dataLayer as $dl_key => $dl_value ) {
|
728 |
-
if ( strpos( $dl_key,
|
729 |
unset( $dataLayer[ $dl_key ] );
|
730 |
}
|
731 |
}
|
@@ -734,20 +754,20 @@ function gtm4wp_filter_visitor_keys( $dataLayer ) {
|
|
734 |
}
|
735 |
|
736 |
/**
|
737 |
-
* GTM4WP global JS variables
|
738 |
*
|
739 |
* @author Vincent Koc <https://github.com/koconder/>
|
740 |
* @link https://github.com/duracelltomi/gtm4wp/issues/34
|
741 |
* @return mixed returns the
|
742 |
*/
|
743 |
-
function gtm4wp_add_global_vars( $vars, $return = false ){
|
744 |
-
if(
|
745 |
-
if(function_exists($vars)){
|
746 |
$vars = $vars();
|
747 |
}
|
748 |
-
$GLOBALS[
|
749 |
}
|
750 |
-
return $GLOBALS[
|
751 |
}
|
752 |
|
753 |
function gtm4wp_wp_header_top( $echo = true ) {
|
@@ -755,12 +775,12 @@ function gtm4wp_wp_header_top( $echo = true ) {
|
|
755 |
|
756 |
$_gtm_top_content = '
|
757 |
<!-- Google Tag Manager for WordPress by gtm4wp.com -->
|
758 |
-
<script data-cfasync="false" type="text/javascript">//<![CDATA[
|
759 |
var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
|
760 |
var ' . $gtm4wp_datalayer_name . ' = ' . $gtm4wp_datalayer_name . ' || [];';
|
761 |
|
762 |
// Load in the global variables from gtm4wp_add_global_vars / GTM4WP_WPACTION_ADDGLOBALVARS filter
|
763 |
-
$_gtm_top_content .= apply_filters(GTM4WP_WPACTION_ADDGLOBALVARS, '', true);
|
764 |
|
765 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
766 |
$_gtm_top_content .= '
|
@@ -777,7 +797,7 @@ function gtm4wp_wp_header_top( $echo = true ) {
|
|
777 |
</script>
|
778 |
<!-- End Google Tag Manager for WordPress by gtm4wp.com -->';
|
779 |
|
780 |
-
if( !gtm4wp_amp_running() ) {
|
781 |
if ( $echo ) {
|
782 |
echo $_gtm_top_content;
|
783 |
} else {
|
@@ -791,23 +811,22 @@ function gtm4wp_wp_header_begin( $echo = true ) {
|
|
791 |
|
792 |
$_gtm_header_content = '
|
793 |
<!-- Google Tag Manager for WordPress by gtm4wp.com -->
|
794 |
-
<script data-cfasync="false" type="text/javascript">//<![CDATA[';
|
795 |
|
796 |
-
if ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] !=
|
797 |
$gtm4wp_datalayer_data = array();
|
798 |
$gtm4wp_datalayer_data = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_DATALAYER, $gtm4wp_datalayer_data );
|
799 |
|
800 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_REMARKETING ] ) {
|
801 |
-
// add
|
802 |
// https://support.google.com/tagmanager/answer/3002580?hl=en
|
803 |
-
|
804 |
-
add_filter( GTM4WP_WPFILTER_COMPILE_REMARKTING, "gtm4wp_filter_visitor_keys" );
|
805 |
$gtm4wp_remarketing_tags = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_REMARKTING, $gtm4wp_datalayer_data );
|
806 |
|
807 |
-
$_gtm_header_content
|
808 |
-
$_gtm_header_content
|
809 |
-
$_gtm_header_content
|
810 |
-
$gtm4wp_datalayer_data[
|
811 |
}
|
812 |
|
813 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DOWNLOADS ] ) {
|
@@ -826,26 +845,76 @@ function gtm4wp_wp_header_begin( $echo = true ) {
|
|
826 |
// Clean up and then push datalayer to AMP
|
827 |
$gtm4wp_datalayer_json = str_replace(
|
828 |
array( '"-~-', '-~-"' ),
|
829 |
-
array(
|
830 |
-
str_replace(
|
831 |
);
|
832 |
|
833 |
$_gtm_header_content .= '
|
834 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
835 |
}
|
836 |
|
837 |
$_gtm_header_content .= '//]]>
|
838 |
</script>';
|
839 |
|
840 |
-
$_gtm_header_content .= apply_filters( GTM4WP_WPFILTER_AFTER_DATALAYER,
|
841 |
|
842 |
-
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] !=
|
843 |
-
$_gtm_codes = explode(
|
844 |
|
845 |
$_gtm_tag = '';
|
846 |
-
foreach( $_gtm_codes as $one_gtm_code ) {
|
847 |
-
if ( (
|
848 |
-
$_gtm_env = "+'>m_auth=" . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] .
|
849 |
} else {
|
850 |
$_gtm_env = '';
|
851 |
}
|
@@ -855,7 +924,7 @@ function gtm4wp_wp_header_begin( $echo = true ) {
|
|
855 |
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
|
856 |
new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
|
857 |
j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
858 |
-
\'//www.googletagmanager.com/gtm.\''.'+\'js?id=\'+i+dl' . $_gtm_env . ';f.parentNode.insertBefore(j,f);
|
859 |
})(window,document,\'script\',\'' . $gtm4wp_datalayer_name . '\',\'' . $one_gtm_code . '\');//]]>
|
860 |
</script>';
|
861 |
}
|
@@ -863,14 +932,14 @@ j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
|
863 |
$_gtm_tag .= '
|
864 |
<!-- End Google Tag Manager -->';
|
865 |
|
866 |
-
$_gtm_tag
|
867 |
$_gtm_header_content .= $_gtm_tag;
|
868 |
}
|
869 |
|
870 |
$_gtm_header_content .= '
|
871 |
<!-- End Google Tag Manager for WordPress by gtm4wp.com -->';
|
872 |
|
873 |
-
if ( !gtm4wp_amp_running() ) {
|
874 |
if ( $echo ) {
|
875 |
echo $_gtm_header_content;
|
876 |
} else {
|
@@ -892,62 +961,66 @@ function gtm4wp_body_class( $classes ) {
|
|
892 |
}
|
893 |
|
894 |
function gtm4wp_wp_login() {
|
895 |
-
setcookie( 'gtm4wp_user_logged_in',
|
896 |
}
|
897 |
|
898 |
function gtm4wp_user_register() {
|
899 |
-
setcookie( 'gtm4wp_user_registered',
|
900 |
}
|
901 |
|
902 |
function gtm4wp_user_reg_login_script() {
|
903 |
global $gtp4wp_plugin_url;
|
904 |
|
905 |
-
$in_footer = apply_filters( 'gtm4wp_user_reg_login_script', true);
|
906 |
-
wp_enqueue_script(
|
907 |
}
|
908 |
|
909 |
function gtm4wp_rocket_excluded_inline_js_content( $pattern ) {
|
910 |
-
$pattern[] =
|
911 |
-
$pattern[] =
|
912 |
|
913 |
return $pattern;
|
914 |
}
|
915 |
|
916 |
-
add_action(
|
917 |
$gtm4wp_header_begin_prior = 10;
|
918 |
-
if ( isset( $GLOBALS[
|
919 |
$gtm4wp_header_begin_prior = 2;
|
920 |
}
|
921 |
-
add_action(
|
922 |
-
add_action(
|
923 |
-
add_action(
|
924 |
-
add_action(
|
925 |
-
add_filter(
|
926 |
-
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER,
|
927 |
|
928 |
// to be able to easily migrate from other Google Tag Manager plugins
|
929 |
-
add_action(
|
930 |
|
931 |
// compatibility with existing themes that natively support code injection after opening body tag
|
932 |
-
add_action(
|
933 |
-
add_action(
|
934 |
-
add_action(
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
|
|
|
|
|
|
|
|
939 |
}
|
940 |
|
941 |
-
if ( isset( $GLOBALS[
|
942 |
-
require_once
|
943 |
}
|
944 |
|
945 |
-
if ( isset( $GLOBALS[
|
946 |
-
add_action(
|
947 |
-
add_action(
|
948 |
}
|
949 |
|
950 |
-
if ( isset( $GLOBALS[
|
951 |
-
add_action(
|
952 |
-
add_action(
|
953 |
-
}
|
1 |
<?php
|
2 |
+
define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER', 'gtm4wp_compile_datalayer' );
|
3 |
define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtm4wp_compile_remarkering' );
|
4 |
+
define( 'GTM4WP_WPFILTER_AFTER_DATALAYER', 'gtm4wp_after_datalayer' );
|
5 |
+
define( 'GTM4WP_WPFILTER_GETTHEGTMTAG', 'gtm4wp_get_the_gtm_tag' );
|
6 |
+
define( 'GTM4WP_WPACTION_ADDGLOBALVARS', 'gtm4wp_add_global_vars' );
|
7 |
|
8 |
+
$GLOBALS['gtm4wp_container_code_written'] = false;
|
9 |
|
10 |
// check for empty is needed to prevent error in WP CLI
|
11 |
// bugfix by Patrick Holberg Hesselberg
|
12 |
+
if ( empty( $GLOBALS['gtm4wp_options'] ) || ( $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_DATALAYER_NAME ] == '' ) ) {
|
13 |
+
$GLOBALS['gtm4wp_datalayer_name'] = 'dataLayer';
|
14 |
} else {
|
15 |
+
$GLOBALS['gtm4wp_datalayer_name'] = $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_DATALAYER_NAME ];
|
16 |
}
|
17 |
|
18 |
// Setting Global Variable to Store JSON based Datalayer for Intergrations
|
19 |
+
$GLOBALS['gtm4wp_datalayer_json'] = '';
|
20 |
+
$GLOBALS['gtm4wp_datalayer_globalvars'] = '';
|
21 |
|
22 |
// Moving include to top due to hierarchy of includes
|
23 |
+
if ( isset( $GLOBALS['gtm4wp_options'] ) && ( '' != $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_INTEGRATE_AMPID ] ) ) {
|
24 |
+
require_once dirname( __FILE__ ) . '/../integration/amp.php';
|
25 |
}
|
26 |
+
if ( ! function_exists( 'gtm4wp_amp_running' ) ) {
|
27 |
+
function gtm4wp_amp_running() {
|
28 |
return false;
|
29 |
}
|
30 |
}
|
35 |
* @author Vincent Koc <https://github.com/koconder/>
|
36 |
* @return mixed Returs object or string false
|
37 |
*/
|
38 |
+
function gtm4wp_escjs_boolean( $obj ) {
|
39 |
+
if ( empty( $obj ) || is_null( $obj ) || ! $obj ) {
|
40 |
return 'false';
|
41 |
+
} else {
|
42 |
return $obj;
|
43 |
}
|
44 |
}
|
45 |
|
46 |
+
function gtm4wp_is_assoc( $arr ) {
|
47 |
// borrowed from
|
48 |
// http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential
|
49 |
+
return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
|
50 |
}
|
51 |
|
52 |
/**
|
56 |
* Code improved by Thomas Geiger
|
57 |
*/
|
58 |
function gtm4wp_ip_is_private( $ip ) {
|
59 |
+
$int_ip = ip2long( $ip );
|
60 |
+
if ( ! empty( $ip ) && $int_ip != -1 && $int_ip !== false ) {
|
61 |
+
$private_ips = array(
|
62 |
+
array( '0.0.0.0', '2.255.255.255' ),
|
63 |
+
array( '10.0.0.0', '10.255.255.255' ),
|
64 |
+
array( '127.0.0.0', '127.255.255.255' ),
|
65 |
+
array( '169.254.0.0', '169.254.255.255' ),
|
66 |
+
array( '172.16.0.0', '172.31.255.255' ),
|
67 |
+
array( '192.0.2.0', '192.0.2.255' ),
|
68 |
+
array( '192.168.0.0', '192.168.255.255' ),
|
69 |
+
array( '255.255.255.0', '255.255.255.255' ),
|
70 |
);
|
71 |
|
72 |
+
foreach ( $private_ips as $private_ip ) {
|
73 |
$min_int_ip = ip2long( $private_ip[0] );
|
74 |
$max_int_ip = ip2long( $private_ip[1] );
|
75 |
+
if ( ( $int_ip >= $min_int_ip ) && ( $int_ip <= $max_int_ip ) ) {
|
76 |
return true;
|
77 |
}
|
78 |
}
|
90 |
* Code improved by Thomas Geiger
|
91 |
*/
|
92 |
function gtm4wp_get_user_ip() {
|
93 |
+
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) && ! gtm4wp_ip_is_private( $_SERVER['HTTP_CLIENT_IP'] ) ) {
|
94 |
+
return $_SERVER['HTTP_CLIENT_IP'];
|
95 |
}
|
96 |
|
97 |
+
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
98 |
+
foreach ( explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ) as $ip ) {
|
99 |
+
if ( ! gtm4wp_ip_is_private( trim( $ip ) ) ) {
|
100 |
return $ip;
|
101 |
}
|
102 |
}
|
103 |
}
|
104 |
|
105 |
+
if ( ! empty( $_SERVER['HTTP_X_FORWARDED'] ) && ! gtm4wp_ip_is_private( $_SERVER['HTTP_X_FORWARDED'] ) ) {
|
106 |
+
return $_SERVER['HTTP_X_FORWARDED'];
|
107 |
+
} elseif ( ! empty( $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] ) && ! gtm4wp_ip_is_private( $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] ) ) {
|
108 |
+
return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
|
109 |
+
} elseif ( ! empty( $_SERVER['HTTP_FORWARDED_FOR'] ) && ! gtm4wp_ip_is_private( $_SERVER['HTTP_FORWARDED_FOR'] ) ) {
|
110 |
+
return $_SERVER['HTTP_FORWARDED_FOR'];
|
111 |
+
} elseif ( ! empty( $_SERVER['HTTP_FORWARDED'] ) && ! gtm4wp_ip_is_private( $_SERVER['HTTP_FORWARDED'] ) ) {
|
112 |
+
return $_SERVER['HTTP_FORWARDED'];
|
113 |
} else {
|
114 |
+
return $_SERVER['REMOTE_ADDR'];
|
115 |
}
|
116 |
}
|
117 |
|
118 |
+
if ( ! function_exists( 'getallheaders' ) ) {
|
119 |
function getallheaders() {
|
120 |
$headers = array();
|
121 |
foreach ( $_SERVER as $name => $value ) {
|
122 |
+
if ( substr( $name, 0, 5 ) == 'HTTP_' ) {
|
123 |
+
$headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
|
124 |
}
|
125 |
}
|
126 |
|
132 |
global $wp_query, $gtm4wp_options;
|
133 |
|
134 |
if ( $gtm4wp_options[ GTM4WP_OPTION_DONOTTRACK ] ) {
|
135 |
+
if ( ! empty( $_SERVER['HTTP_DNT'] ) ) {
|
136 |
+
$dataLayer['visitorDoNotTrack'] = (int) ( $_SERVER['HTTP_DNT'] );
|
137 |
} else {
|
138 |
+
$dataLayer['visitorDoNotTrack'] = 0;
|
139 |
}
|
140 |
}
|
141 |
|
142 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_SITEID ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_SITENAME ] ) {
|
143 |
+
$dataLayer['siteID'] = 0;
|
144 |
+
$dataLayer['siteName'] = '';
|
145 |
|
146 |
if ( function_exists( 'get_blog_details' ) ) {
|
147 |
$gtm4wp_blogdetails = get_blog_details();
|
148 |
|
149 |
+
$dataLayer['siteID'] = $gtm4wp_blogdetails->blog_id;
|
150 |
+
$dataLayer['siteName'] = $gtm4wp_blogdetails->blogname;
|
151 |
}
|
152 |
}
|
153 |
|
154 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_LOGGEDIN ] ) {
|
155 |
if ( is_user_logged_in() ) {
|
156 |
+
$dataLayer['visitorLoginState'] = 'logged-in';
|
157 |
} else {
|
158 |
+
$dataLayer['visitorLoginState'] = 'logged-out';
|
159 |
}
|
160 |
}
|
161 |
|
163 |
$current_user = wp_get_current_user();
|
164 |
|
165 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERROLE ] ) {
|
166 |
+
$dataLayer['visitorType'] = ( empty( $current_user->roles[0] ) ? 'visitor-logged-out' : $current_user->roles[0] );
|
167 |
}
|
168 |
|
169 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USEREMAIL ] ) {
|
170 |
+
$dataLayer['visitorEmail'] = ( empty( $current_user->user_email ) ? '' : $current_user->user_email );
|
171 |
}
|
172 |
|
173 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERREGDATE ] ) {
|
174 |
+
$dataLayer['visitorRegistrationDate'] = ( empty( $current_user->user_registered ) ? '' : strtotime( $current_user->user_registered ) );
|
175 |
}
|
176 |
|
177 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERNAME ] ) {
|
178 |
+
$dataLayer['visitorUsername'] = ( empty( $current_user->user_login ) ? '' : $current_user->user_login );
|
179 |
}
|
180 |
}
|
181 |
|
182 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERID ] ) {
|
183 |
$_gtm4wp_userid = get_current_user_id();
|
184 |
if ( $_gtm4wp_userid > 0 ) {
|
185 |
+
$dataLayer['visitorId'] = $_gtm4wp_userid;
|
186 |
}
|
187 |
}
|
188 |
|
189 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_VISITOR_IP ] ) {
|
190 |
+
$dataLayer['visitorIP'] = esc_js( gtm4wp_get_user_ip() );
|
191 |
}
|
192 |
|
193 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
|
194 |
+
$dataLayer['pageTitle'] = strip_tags( wp_title( '|', false, 'right' ) );
|
195 |
}
|
196 |
|
197 |
if ( is_singular() ) {
|
198 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
199 |
+
$dataLayer['pagePostType'] = get_post_type();
|
200 |
+
$dataLayer['pagePostType2'] = 'single-' . get_post_type();
|
201 |
}
|
202 |
|
203 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_CATEGORIES ] ) {
|
204 |
$_post_cats = get_the_category();
|
205 |
if ( $_post_cats ) {
|
206 |
+
$dataLayer['pageCategory'] = array();
|
207 |
+
foreach ( $_post_cats as $_one_cat ) {
|
208 |
+
$dataLayer['pageCategory'][] = $_one_cat->slug;
|
209 |
}
|
210 |
}
|
211 |
}
|
213 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_TAGS ] ) {
|
214 |
$_post_tags = get_the_tags();
|
215 |
if ( $_post_tags ) {
|
216 |
+
$dataLayer['pageAttributes'] = array();
|
217 |
+
foreach ( $_post_tags as $_one_tag ) {
|
218 |
+
$dataLayer['pageAttributes'][] = $_one_tag->slug;
|
219 |
}
|
220 |
}
|
221 |
}
|
222 |
|
223 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) {
|
224 |
+
$postuser = get_userdata( $GLOBALS['post']->post_author );
|
225 |
|
226 |
if ( false !== $postuser ) {
|
227 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] ) {
|
228 |
+
$dataLayer['pagePostAuthorID'] = $postuser->ID;
|
229 |
}
|
230 |
|
231 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) {
|
232 |
+
$dataLayer['pagePostAuthor'] = $postuser->display_name;
|
233 |
}
|
234 |
}
|
235 |
}
|
236 |
|
237 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
238 |
+
$dataLayer['pagePostDate'] = get_the_date();
|
239 |
+
$dataLayer['pagePostDateYear'] = get_the_date( 'Y' );
|
240 |
+
$dataLayer['pagePostDateMonth'] = get_the_date( 'm' );
|
241 |
+
$dataLayer['pagePostDateDay'] = get_the_date( 'd' );
|
242 |
+
}
|
243 |
+
|
244 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTERMLIST ] ) {
|
245 |
+
$dataLayer["pagePostTerms"] = array();
|
246 |
+
$object_taxonomies = get_object_taxonomies( get_post_type() );
|
247 |
+
foreach( $object_taxonomies as $one_object_taxonomy ) {
|
248 |
+
$post_taxonomy_values = get_the_terms( $GLOBALS[ "post" ]->ID, $one_object_taxonomy );
|
249 |
+
if ( is_array( $post_taxonomy_values ) ) {
|
250 |
+
$dataLayer["pagePostTerms"][$one_object_taxonomy] = array();
|
251 |
+
foreach( $post_taxonomy_values as $one_taxonomy_value ) {
|
252 |
+
$dataLayer["pagePostTerms"][$one_object_taxonomy][] = $one_taxonomy_value->name;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
}
|
257 |
}
|
258 |
|
259 |
if ( is_archive() || is_post_type_archive() ) {
|
260 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
261 |
+
$dataLayer['pagePostType'] = get_post_type();
|
262 |
|
263 |
if ( is_category() ) {
|
264 |
+
$dataLayer['pagePostType2'] = 'category-' . get_post_type();
|
265 |
+
} elseif ( is_tag() ) {
|
266 |
+
$dataLayer['pagePostType2'] = 'tag-' . get_post_type();
|
267 |
+
} elseif ( is_tax() ) {
|
268 |
+
$dataLayer['pagePostType2'] = 'tax-' . get_post_type();
|
269 |
+
} elseif ( is_author() ) {
|
270 |
+
$dataLayer['pagePostType2'] = 'author-' . get_post_type();
|
271 |
+
} elseif ( is_year() ) {
|
272 |
+
$dataLayer['pagePostType2'] = 'year-' . get_post_type();
|
273 |
|
274 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
275 |
+
$dataLayer['pagePostDateYear'] = get_the_date( 'Y' );
|
276 |
}
|
277 |
+
} elseif ( is_month() ) {
|
278 |
+
$dataLayer['pagePostType2'] = 'month-' . get_post_type();
|
279 |
|
280 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
281 |
+
$dataLayer['pagePostDateYear'] = get_the_date( 'Y' );
|
282 |
+
$dataLayer['pagePostDateMonth'] = get_the_date( 'm' );
|
283 |
}
|
284 |
+
} elseif ( is_day() ) {
|
285 |
+
$dataLayer['pagePostType2'] = 'day-' . get_post_type();
|
286 |
|
287 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
288 |
+
$dataLayer['pagePostDate'] = get_the_date();
|
289 |
+
$dataLayer['pagePostDateYear'] = get_the_date( 'Y' );
|
290 |
+
$dataLayer['pagePostDateMonth'] = get_the_date( 'm' );
|
291 |
+
$dataLayer['pagePostDateDay'] = get_the_date( 'd' );
|
292 |
}
|
293 |
+
} elseif ( is_time() ) {
|
294 |
+
$dataLayer['pagePostType2'] = 'time-' . get_post_type();
|
295 |
+
} elseif ( is_date() ) {
|
296 |
+
$dataLayer['pagePostType2'] = 'date-' . get_post_type();
|
297 |
|
298 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
299 |
+
$dataLayer['pagePostDate'] = get_the_date();
|
300 |
+
$dataLayer['pagePostDateYear'] = get_the_date( 'Y' );
|
301 |
+
$dataLayer['pagePostDateMonth'] = get_the_date( 'm' );
|
302 |
+
$dataLayer['pagePostDateDay'] = get_the_date( 'd' );
|
303 |
}
|
304 |
}
|
305 |
}
|
306 |
|
307 |
if ( ( is_tax() || is_category() ) && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_CATEGORIES ] ) {
|
308 |
+
$_post_cats = get_the_category();
|
309 |
+
$dataLayer['pageCategory'] = array();
|
310 |
+
foreach ( $_post_cats as $_one_cat ) {
|
311 |
+
$dataLayer['pageCategory'][] = $_one_cat->slug;
|
312 |
}
|
313 |
}
|
314 |
|
315 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] ) && ( is_author() ) ) {
|
316 |
global $authordata;
|
317 |
+
$dataLayer['pagePostAuthorID'] = isset( $authordata->ID ) ? $authordata->ID : 0;
|
318 |
}
|
319 |
|
320 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) && ( is_author() ) ) {
|
321 |
+
$dataLayer['pagePostAuthor'] = get_the_author();
|
322 |
}
|
323 |
}
|
324 |
|
325 |
if ( is_search() ) {
|
326 |
+
$dataLayer['siteSearchTerm'] = get_search_query();
|
327 |
+
$dataLayer['siteSearchFrom'] = '';
|
328 |
+
if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
|
329 |
+
$referer_url_parts = explode( '?', $_SERVER['HTTP_REFERER'] );
|
330 |
if ( count( $referer_url_parts ) > 1 ) {
|
331 |
+
$dataLayer['siteSearchFrom'] = $referer_url_parts[0] . '?' . rawurlencode( $referer_url_parts[1] );
|
332 |
} else {
|
333 |
+
$dataLayer['siteSearchFrom'] = $referer_url_parts[0];
|
334 |
}
|
335 |
}
|
336 |
+
$dataLayer['siteSearchResults'] = $wp_query->post_count;
|
337 |
}
|
338 |
|
339 |
if ( is_front_page() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
340 |
+
$dataLayer['pagePostType'] = 'frontpage';
|
341 |
}
|
342 |
|
343 |
+
if ( ! is_front_page() && is_home() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
344 |
+
$dataLayer['pagePostType'] = 'bloghome';
|
345 |
}
|
346 |
|
347 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
348 |
+
spl_autoload_register(
|
349 |
+
function( $class ) {
|
350 |
+
$class_parts = explode( '\\', $class );
|
351 |
+
if ( 'WhichBrowser' == $class_parts[0] ) {
|
352 |
+
include dirname( __FILE__ ) . '/../integration/whichbrowser/' . str_replace( array( 'WhichBrowser', '\\' ), array( 'src', '/' ), $class ) . '.php';
|
353 |
+
}
|
354 |
}
|
355 |
+
);
|
356 |
|
357 |
+
require_once dirname( __FILE__ ) . '/../integration/whichbrowser/src/Parser.php';
|
358 |
|
359 |
$gtp4wp_headers = getallheaders();
|
360 |
if ( ( false === $gtp4wp_headers ) && isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
361 |
$gtp4wp_headers = $_SERVER['HTTP_USER_AGENT'];
|
362 |
}
|
363 |
if ( false !== $gtp4wp_headers ) {
|
364 |
+
$detected = new WhichBrowser\Parser( $gtp4wp_headers );
|
365 |
|
366 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] ) {
|
367 |
+
$dataLayer['browserName'] = isset( $detected->browser->name ) ? $detected->browser->name : '';
|
368 |
+
$dataLayer['browserVersion'] = isset( $detected->browser->version->value ) ? $detected->browser->version->value : '';
|
369 |
|
370 |
+
$dataLayer['browserEngineName'] = isset( $detected->engine->name ) ? $detected->engine->name : '';
|
371 |
+
$dataLayer['browserEngineVersion'] = isset( $detected->engine->version->value ) ? $detected->engine->version->value : '';
|
372 |
}
|
373 |
|
374 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] ) {
|
375 |
+
$dataLayer['osName'] = isset( $detected->os->name ) ? $detected->os->name : '';
|
376 |
+
$dataLayer['osVersion'] = isset( $detected->os->version->value ) ? $detected->os->version->value : '';
|
377 |
}
|
378 |
|
379 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
380 |
+
$dataLayer['deviceType'] = isset( $detected->device->type ) ? $detected->device->type : '';
|
381 |
+
$dataLayer['deviceManufacturer'] = isset( $detected->device->manufacturer ) ? $detected->device->manufacturer : '';
|
382 |
+
$dataLayer['deviceModel'] = isset( $detected->device->model ) ? $detected->device->model : '';
|
383 |
}
|
384 |
}
|
385 |
}
|
386 |
|
387 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTCOUNT ] ) {
|
388 |
+
$dataLayer['postCountOnPage'] = (int) $wp_query->post_count;
|
389 |
+
$dataLayer['postCountTotal'] = (int) $wp_query->found_posts;
|
390 |
}
|
391 |
|
392 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTID ] && is_singular() === true ) {
|
393 |
+
$dataLayer['postID'] = (int) get_the_ID();
|
394 |
}
|
395 |
|
396 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTFORMAT ] && is_singular() === true ) {
|
397 |
+
$dataLayer['postFormat'] = get_post_format() ?: 'standard';
|
398 |
}
|
399 |
|
400 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] > 0 ) {
|
402 |
|
403 |
// IDs from https://developers.google.com/tag-manager/devguide#security
|
404 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ADADVISOR ] ) {
|
405 |
+
$_gtmrestrictlistitems[] = 'ta';
|
406 |
}
|
407 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ADROLL ] ) {
|
408 |
+
$_gtmrestrictlistitems[] = 'asp';
|
409 |
}
|
410 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_AWCONV ] ) {
|
411 |
+
$_gtmrestrictlistitems[] = 'awct';
|
412 |
}
|
413 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_AWREMARKET ] ) {
|
414 |
+
$_gtmrestrictlistitems[] = 'sp';
|
415 |
}
|
416 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_BIZO ] ) {
|
417 |
+
$_gtmrestrictlistitems[] = 'bzi';
|
418 |
}
|
419 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CLICKTALE ] ) {
|
420 |
+
$_gtmrestrictlistitems[] = 'cts';
|
421 |
}
|
422 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_COMSCORE ] ) {
|
423 |
+
$_gtmrestrictlistitems[] = 'csm';
|
424 |
}
|
425 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CUSTOMHTML ] ) {
|
426 |
+
$_gtmrestrictlistitems[] = 'html';
|
427 |
}
|
428 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CUSTOMIMG ] ) {
|
429 |
+
$_gtmrestrictlistitems[] = 'img';
|
430 |
}
|
431 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT ] ) {
|
432 |
+
$_gtmrestrictlistitems[] = 'flc';
|
433 |
}
|
434 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_DBLCLKSALES ] ) {
|
435 |
+
$_gtmrestrictlistitems[] = 'fls';
|
436 |
}
|
437 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_GACLASSIC ] ) {
|
438 |
+
$_gtmrestrictlistitems[] = 'ga';
|
439 |
}
|
440 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MARIN ] ) {
|
441 |
+
$_gtmrestrictlistitems[] = 'ms';
|
442 |
}
|
443 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME ] ) {
|
444 |
+
$_gtmrestrictlistitems[] = 'mpm';
|
445 |
}
|
446 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MPLEXROI ] ) {
|
447 |
+
$_gtmrestrictlistitems[] = 'mpr';
|
448 |
}
|
449 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MEDIA6DEG ] ) {
|
450 |
+
$_gtmrestrictlistitems[] = 'm6d';
|
451 |
}
|
452 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_TURNCONV ] ) {
|
453 |
+
$_gtmrestrictlistitems[] = 'tc';
|
454 |
}
|
455 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_TURNDATA ] ) {
|
456 |
+
$_gtmrestrictlistitems[] = 'tdc';
|
457 |
}
|
458 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_UA ] ) {
|
459 |
+
$_gtmrestrictlistitems[] = 'ua';
|
460 |
}
|
461 |
|
462 |
$_gtmwhitelist = array();
|
463 |
$_gtmblacklist = array();
|
464 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 1 ) {
|
465 |
+
$_gtmblacklist = array_merge( $_gtmblacklist, $_gtmrestrictlistitems );
|
466 |
} else {
|
467 |
+
$_gtmwhitelist = array_merge( $_gtmwhitelist, $_gtmrestrictlistitems );
|
468 |
}
|
469 |
|
470 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT ] ) {
|
471 |
+
$_gtmwhitelist[] = 'd';
|
472 |
}
|
473 |
|
474 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS ] ) {
|
475 |
+
$_gtmwhitelist[] = 'jsm';
|
476 |
}
|
477 |
|
478 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT ] ) {
|
479 |
+
$_gtmwhitelist[] = 'c';
|
480 |
}
|
481 |
|
482 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE ] ) {
|
483 |
+
$_gtmwhitelist[] = 'k';
|
484 |
}
|
485 |
|
486 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME ] ) {
|
487 |
+
$_gtmwhitelist[] = 'e';
|
488 |
}
|
489 |
|
490 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR ] ) {
|
491 |
+
$_gtmwhitelist[] = 'j';
|
492 |
}
|
493 |
|
494 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR ] ) {
|
495 |
+
$_gtmwhitelist[] = 'v';
|
496 |
}
|
497 |
|
498 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM ] ) {
|
499 |
+
$_gtmwhitelist[] = 'r';
|
500 |
}
|
501 |
|
502 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER ] ) {
|
503 |
+
$_gtmwhitelist[] = 'f';
|
504 |
}
|
505 |
|
506 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_URL ] ) {
|
507 |
+
$_gtmwhitelist[] = 'u';
|
508 |
}
|
509 |
|
510 |
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT ] ) {
|
511 |
+
$_gtmwhitelist[] = 'v';
|
512 |
}
|
513 |
|
514 |
+
$dataLayer['gtm.whitelist'] = $_gtmwhitelist;
|
515 |
+
$dataLayer['gtm.blacklist'] = $_gtmblacklist;
|
516 |
}
|
517 |
|
518 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEOCF ] && isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) {
|
519 |
+
$dataLayer['geoCloudflareCountryCode'] = $_SERVER['HTTP_CF_IPCOUNTRY'];
|
520 |
+
}
|
521 |
+
|
522 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
|
523 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
|
524 |
+
$dataLayer['weatherCategory'] = __( '(no weather data available)', 'duracelltomi-google-tag-manager' );
|
525 |
+
$dataLayer['weatherDescription'] = __( '(no weather data available)', 'duracelltomi-google-tag-manager' );
|
526 |
+
$dataLayer['weatherTemp'] = 0;
|
527 |
+
$dataLayer['weatherPressure'] = 0;
|
528 |
+
$dataLayer['weatherWindSpeed'] = 0;
|
529 |
+
$dataLayer['weatherWindDeg'] = 0;
|
530 |
+
$dataLayer['weatherDataStatus'] = 'Initialized with empty data';
|
531 |
}
|
532 |
|
533 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
|
534 |
+
$dataLayer['geoCountryCode'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
535 |
+
$dataLayer['geoCountryName'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
536 |
+
$dataLayer['geoRegionCode'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
537 |
+
$dataLayer['geoRegionName'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
538 |
+
$dataLayer['geoCity'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
539 |
+
$dataLayer['geoZipcode'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
540 |
+
$dataLayer['geoLatitude'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
541 |
+
$dataLayer['geoLongitude'] = __( '(no geo data available)', 'duracelltomi-google-tag-manager' );
|
542 |
}
|
543 |
|
544 |
$client_ip = gtm4wp_get_user_ip();
|
545 |
|
546 |
+
if ( '' !== $client_ip ) {
|
547 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
|
548 |
$weatherdata = get_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ) );
|
549 |
|
550 |
if ( false !== $weatherdata ) {
|
551 |
+
$dataLayer['weatherCategory'] = $weatherdata->weather[0]->main;
|
552 |
+
$dataLayer['weatherDescription'] = $weatherdata->weather[0]->description;
|
553 |
+
$dataLayer['weatherTemp'] = $weatherdata->main->temp;
|
554 |
+
$dataLayer['weatherPressure'] = $weatherdata->main->pressure;
|
555 |
+
$dataLayer['weatherWindSpeed'] = $weatherdata->wind->speed;
|
556 |
+
$dataLayer['weatherWindDeg'] = ( $weatherdata->wind->deg ? $weatherdata->wind->deg : '' );
|
557 |
+
$dataLayer['weatherFullWeatherData'] = $weatherdata;
|
558 |
+
$dataLayer['weatherDataStatus'] = 'Read from cache';
|
559 |
} else {
|
560 |
+
$dataLayer['weatherDataStatus'] = 'No weather data in cache (' . esc_attr( $client_ip ) . ')';
|
561 |
}
|
562 |
}
|
563 |
|
565 |
$geodata = get_transient( 'gtm4wp-geodata-' . esc_attr( $client_ip ) );
|
566 |
|
567 |
if ( false !== $geodata ) {
|
568 |
+
$dataLayer['geoFullGeoData'] = $geodata;
|
569 |
|
570 |
if ( isset( $geodata->latitude ) ) {
|
571 |
+
$dataLayer['geoCountryCode'] = $geodata->country_code;
|
572 |
+
$dataLayer['geoCountryName'] = $geodata->country_name;
|
573 |
+
$dataLayer['geoRegionCode'] = $geodata->region_code;
|
574 |
+
$dataLayer['geoRegionName'] = $geodata->region_name;
|
575 |
+
$dataLayer['geoCity'] = $geodata->city;
|
576 |
+
$dataLayer['geoZipcode'] = $geodata->zip;
|
577 |
+
$dataLayer['geoLatitude'] = $geodata->latitude;
|
578 |
+
$dataLayer['geoLongitude'] = $geodata->longitude;
|
579 |
}
|
580 |
}
|
581 |
}
|
595 |
if ( false === $geodata ) {
|
596 |
$gtm4wp_geodata = @wp_remote_get( sprintf( 'http://api.ipstack.com/%s?access_key=%s&format=1', urlencode( $client_ip ), $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEOAPI ] ) );
|
597 |
|
598 |
+
if ( is_array( $gtm4wp_geodata ) && ( 200 == $gtm4wp_geodata['response']['code'] ) ) {
|
599 |
+
$gtm4wp_geodata = @json_decode( $gtm4wp_geodata['body'] );
|
600 |
|
601 |
if ( is_object( $gtm4wp_geodata ) ) {
|
602 |
set_transient( 'gtm4wp-geodata-' . esc_attr( $client_ip ), $gtm4wp_geodata, 60 * 60 );
|
604 |
$weatherdata = get_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ) );
|
605 |
if ( false === $weatherdata && isset( $gtm4wp_geodata->latitude ) ) {
|
606 |
|
607 |
+
$weatherdata = wp_remote_get( 'http://api.openweathermap.org/data/2.5/weather?appid=' . $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI ] . '&lat=' . $gtm4wp_geodata->latitude . '&lon=' . $gtm4wp_geodata->longitude . '&units=' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'metric' : 'imperial' ) );
|
608 |
|
609 |
+
if ( is_array( $weatherdata ) && ( 200 == $weatherdata['response']['code'] ) ) {
|
610 |
+
$weatherdata = @json_decode( $weatherdata['body'] );
|
611 |
|
612 |
if ( is_object( $weatherdata ) ) {
|
613 |
set_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ), $weatherdata, 60 * 60 );
|
614 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'Weather data loaded.' );
|
615 |
} else {
|
616 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'Openweathermap.org did not return processable data: ' . var_dump( $weatherdata, true ) );
|
617 |
}
|
618 |
} else {
|
619 |
if ( is_wp_error( $weatherdata ) ) {
|
620 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'Openweathermap.org request error: ' . $weatherdata->get_error_message() );
|
621 |
} else {
|
622 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'Openweathermap.org returned status code: ' . $weatherdata['response']['code'] );
|
623 |
}
|
624 |
}
|
625 |
}
|
626 |
} else {
|
627 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'ipstack.com did not return lat-lng data: ' . var_dump( $gtm4wp_geodata, true ) );
|
628 |
}
|
629 |
} else {
|
630 |
if ( is_wp_error( $gtm4wp_geodata ) ) {
|
631 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'ipstack.com request error: ' . $gtm4wp_geodata->get_error_message() );
|
632 |
} else {
|
633 |
+
setcookie( 'gtm4wp_last_weatherstatus', 'ipstack.com returned status code: ' . $gtm4wp_geodata['response']['code'] );
|
634 |
}
|
635 |
}
|
636 |
}
|
647 |
$gtm4wp_container_code_written = true;
|
648 |
}
|
649 |
|
650 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != '' ) && ( ! $gtm4wp_container_code_written ) ) {
|
651 |
+
$_gtm_codes = explode( ',', str_replace( array( ';', ' ' ), array( ',', '' ), $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) );
|
652 |
|
653 |
+
if ( ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] ) ) {
|
654 |
+
$_gtm_env = '>m_auth=' . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] . '>m_preview=' . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] . '>m_cookies_win=x';
|
655 |
} else {
|
656 |
$_gtm_env = '';
|
657 |
}
|
658 |
|
659 |
+
foreach ( $_gtm_codes as $one_gtm_code ) {
|
660 |
$_gtm_tag .= '
|
661 |
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' . $one_gtm_code . $_gtm_env . '"
|
662 |
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>';
|
665 |
$_gtm_tag .= '
|
666 |
<!-- End Google Tag Manager (noscript) -->';
|
667 |
|
668 |
+
$_gtm_tag = apply_filters( GTM4WP_WPFILTER_GETTHEGTMTAG, $_gtm_tag );
|
669 |
$gtm4wp_container_code_written = true;
|
670 |
}
|
671 |
|
680 |
global $gtm4wp_options, $gtp4wp_plugin_url;
|
681 |
|
682 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) {
|
683 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_OUTBOUND, false );
|
684 |
+
wp_enqueue_script( 'gtm4wp-outbound-click-tracker', $gtp4wp_plugin_url . 'js/gtm4wp-outbound-click-tracker.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
685 |
}
|
686 |
|
687 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DOWNLOADS ] ) {
|
688 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_DOWNLOADS, false );
|
689 |
+
wp_enqueue_script( 'gtm4wp-download-tracker', $gtp4wp_plugin_url . 'js/gtm4wp-download-tracker.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
690 |
}
|
691 |
|
692 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_EMAILCLICKS ] ) {
|
693 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_EMAILCLICKS, false );
|
694 |
+
wp_enqueue_script( 'gtm4wp-email-link-tracker', $gtp4wp_plugin_url . 'js/gtm4wp-email-link-tracker.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
695 |
}
|
696 |
|
697 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WPCF7 ] ) {
|
698 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WPCF7, false );
|
699 |
+
wp_enqueue_script( 'gtm4wp-contact-form-7-tracker', $gtp4wp_plugin_url . 'js/gtm4wp-contact-form-7-tracker.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
700 |
}
|
701 |
|
702 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_FORMMOVE ] ) {
|
703 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_FORMMOVE, false );
|
704 |
+
wp_enqueue_script( 'gtm4wp-form-move-tracker', $gtp4wp_plugin_url . 'js/gtm4wp-form-move-tracker.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
705 |
}
|
706 |
|
707 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOCIAL ] ) {
|
708 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_SOCIAL, false );
|
709 |
+
wp_enqueue_script( 'gtm4wp-social-actions', $gtp4wp_plugin_url . 'js/gtm4wp-social-tracker.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
710 |
}
|
711 |
|
712 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_YOUTUBE ] ) {
|
713 |
+
require_once dirname( __FILE__ ) . '/../integration/youtube.php';
|
714 |
}
|
715 |
|
716 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_VIMEO ] ) {
|
717 |
+
require_once dirname( __FILE__ ) . '/../integration/vimeo.php';
|
718 |
}
|
719 |
|
720 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOUNDCLOUD ] ) {
|
721 |
+
require_once dirname( __FILE__ ) . '/../integration/soundcloud.php';
|
722 |
}
|
723 |
|
724 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
725 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_SCROLLER_ENABLED, false );
|
726 |
+
wp_enqueue_script( 'gtm4wp-scroll-tracking', $gtp4wp_plugin_url . 'js/analytics-talk-content-tracking.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
727 |
}
|
728 |
}
|
729 |
|
744 |
}
|
745 |
|
746 |
function gtm4wp_filter_visitor_keys( $dataLayer ) {
|
747 |
+
foreach ( $dataLayer as $dl_key => $dl_value ) {
|
748 |
+
if ( strpos( $dl_key, 'visitor' ) !== false ) {
|
749 |
unset( $dataLayer[ $dl_key ] );
|
750 |
}
|
751 |
}
|
754 |
}
|
755 |
|
756 |
/**
|
757 |
+
* GTM4WP global JS variables WordPress filter
|
758 |
*
|
759 |
* @author Vincent Koc <https://github.com/koconder/>
|
760 |
* @link https://github.com/duracelltomi/gtm4wp/issues/34
|
761 |
* @return mixed returns the
|
762 |
*/
|
763 |
+
function gtm4wp_add_global_vars( $vars, $return = false ) {
|
764 |
+
if ( ! $return ) {
|
765 |
+
if ( function_exists( $vars ) ) {
|
766 |
$vars = $vars();
|
767 |
}
|
768 |
+
$GLOBALS['gtm4wp_datalayer_globalvars'] = $GLOBALS['gtm4wp_datalayer_globalvars'] . ' ' . $vars;
|
769 |
}
|
770 |
+
return $GLOBALS['gtm4wp_datalayer_globalvars'];
|
771 |
}
|
772 |
|
773 |
function gtm4wp_wp_header_top( $echo = true ) {
|
775 |
|
776 |
$_gtm_top_content = '
|
777 |
<!-- Google Tag Manager for WordPress by gtm4wp.com -->
|
778 |
+
<script data-cfasync="false" data-pagespeed-no-defer type="text/javascript">//<![CDATA[
|
779 |
var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
|
780 |
var ' . $gtm4wp_datalayer_name . ' = ' . $gtm4wp_datalayer_name . ' || [];';
|
781 |
|
782 |
// Load in the global variables from gtm4wp_add_global_vars / GTM4WP_WPACTION_ADDGLOBALVARS filter
|
783 |
+
$_gtm_top_content .= apply_filters( GTM4WP_WPACTION_ADDGLOBALVARS, '', true );
|
784 |
|
785 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
786 |
$_gtm_top_content .= '
|
797 |
</script>
|
798 |
<!-- End Google Tag Manager for WordPress by gtm4wp.com -->';
|
799 |
|
800 |
+
if ( ! gtm4wp_amp_running() ) {
|
801 |
if ( $echo ) {
|
802 |
echo $_gtm_top_content;
|
803 |
} else {
|
811 |
|
812 |
$_gtm_header_content = '
|
813 |
<!-- Google Tag Manager for WordPress by gtm4wp.com -->
|
814 |
+
<script data-cfasync="false" data-pagespeed-no-defer type="text/javascript">//<![CDATA[';
|
815 |
|
816 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != '' ) {
|
817 |
$gtm4wp_datalayer_data = array();
|
818 |
$gtm4wp_datalayer_data = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_DATALAYER, $gtm4wp_datalayer_data );
|
819 |
|
820 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_REMARKETING ] ) {
|
821 |
+
// add Google Ads remarketing tags as suggested here:
|
822 |
// https://support.google.com/tagmanager/answer/3002580?hl=en
|
823 |
+
add_filter( GTM4WP_WPFILTER_COMPILE_REMARKTING, 'gtm4wp_filter_visitor_keys' );
|
|
|
824 |
$gtm4wp_remarketing_tags = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_REMARKTING, $gtm4wp_datalayer_data );
|
825 |
|
826 |
+
$_gtm_header_content .= "\nvar google_tag_params = ";
|
827 |
+
$_gtm_header_content .= json_encode( $gtm4wp_remarketing_tags );
|
828 |
+
$_gtm_header_content .= ';';
|
829 |
+
$gtm4wp_datalayer_data['google_tag_params'] = '-~-window.google_tag_params-~-';
|
830 |
}
|
831 |
|
832 |
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DOWNLOADS ] ) {
|
845 |
// Clean up and then push datalayer to AMP
|
846 |
$gtm4wp_datalayer_json = str_replace(
|
847 |
array( '"-~-', '-~-"' ),
|
848 |
+
array( '', '' ),
|
849 |
+
str_replace( '', '-', $gtm4wp_datalayer_json )
|
850 |
);
|
851 |
|
852 |
$_gtm_header_content .= '
|
853 |
+
var dataLayer_content = ' . $gtm4wp_datalayer_json . ';
|
854 |
+
|
855 |
+
// if dataLayer contains ecommerce purchase data, check whether it has been already tracked
|
856 |
+
if ( dataLayer_content.transactionId || ( dataLayer_content.ecommerce && dataLayer_content.ecommerce.purchase ) ) {
|
857 |
+
// read order id already tracked from cookies
|
858 |
+
var gtm4wp_orderid_tracked = "";
|
859 |
+
var gtm4wp_cookie = "; " + document.cookie;
|
860 |
+
var gtm4wp_cookie_parts = gtm4wp_cookie.split( "; gtm4wp_orderid_tracked=" );
|
861 |
+
if ( gtm4wp_cookie_parts.length == 2 ) {
|
862 |
+
gtm4wp_orderid_tracked = gtm4wp_cookie_parts.pop().split(";").shift();
|
863 |
+
}
|
864 |
+
|
865 |
+
// check enhanced ecommerce
|
866 |
+
if ( dataLayer_content.ecommerce && dataLayer_content.ecommerce.purchase ) {
|
867 |
+
if ( gtm4wp_orderid_tracked && ( dataLayer_content.ecommerce.purchase.actionField.id == gtm4wp_orderid_tracked ) ) {
|
868 |
+
delete dataLayer_content.ecommerce.purchase;
|
869 |
+
} else {
|
870 |
+
gtm4wp_orderid_tracked = dataLayer_content.ecommerce.purchase.actionField.id;
|
871 |
+
}
|
872 |
+
}
|
873 |
+
|
874 |
+
// check standard ecommerce
|
875 |
+
if ( dataLayer_content.transactionId ) {
|
876 |
+
if ( gtm4wp_orderid_tracked && ( dataLayer_content.transactionId == gtm4wp_orderid_tracked ) ) {
|
877 |
+
delete dataLayer_content.transactionId;
|
878 |
+
delete dataLayer_content.transactionDate;
|
879 |
+
delete dataLayer_content.transactionType;
|
880 |
+
delete dataLayer_content.transactionAffiliation;
|
881 |
+
delete dataLayer_content.transactionTotal;
|
882 |
+
delete dataLayer_content.transactionShipping;
|
883 |
+
delete dataLayer_content.transactionTax;
|
884 |
+
delete dataLayer_content.transactionPaymentType;
|
885 |
+
delete dataLayer_content.transactionCurrency;
|
886 |
+
delete dataLayer_content.transactionShippingMethod;
|
887 |
+
delete dataLayer_content.transactionPromoCode;
|
888 |
+
delete dataLayer_content.transactionProducts;
|
889 |
+
} else {
|
890 |
+
gtm4wp_orderid_tracked = dataLayer_content.transactionId;
|
891 |
+
}
|
892 |
+
}
|
893 |
+
|
894 |
+
if ( gtm4wp_orderid_tracked ) {
|
895 |
+
var gtm4wp_orderid_cookie_expire = new Date();
|
896 |
+
gtm4wp_orderid_cookie_expire.setTime( gtm4wp_orderid_cookie_expire.getTime() + (365*24*60*60*1000) );
|
897 |
+
var gtm4wp_orderid_cookie_expires = "expires="+ gtm4wp_orderid_cookie_expire.toUTCString();
|
898 |
+
document.cookie = "gtm4wp_orderid_cookie_expire=" + gtm4wp_orderid_tracked + ";" + gtm4wp_orderid_cookie_expire + ";path=/";
|
899 |
+
}
|
900 |
+
|
901 |
+
}
|
902 |
+
|
903 |
+
' . $gtm4wp_datalayer_name . '.push( dataLayer_content );';
|
904 |
}
|
905 |
|
906 |
$_gtm_header_content .= '//]]>
|
907 |
</script>';
|
908 |
|
909 |
+
$_gtm_header_content .= apply_filters( GTM4WP_WPFILTER_AFTER_DATALAYER, '' );
|
910 |
|
911 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != '' ) && ( GTM4WP_PLACEMENT_OFF != $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) ) {
|
912 |
+
$_gtm_codes = explode( ',', str_replace( array( ';', ' ' ), array( ',', '' ), $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) );
|
913 |
|
914 |
$_gtm_tag = '';
|
915 |
+
foreach ( $_gtm_codes as $one_gtm_code ) {
|
916 |
+
if ( ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] ) ) {
|
917 |
+
$_gtm_env = "+'>m_auth=" . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] . '>m_preview=' . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] . ">m_cookies_win=x'";
|
918 |
} else {
|
919 |
$_gtm_env = '';
|
920 |
}
|
924 |
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
|
925 |
new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
|
926 |
j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
927 |
+
\'//www.googletagmanager.com/gtm.\'' . '+\'js?id=\'+i+dl' . $_gtm_env . ';f.parentNode.insertBefore(j,f);
|
928 |
})(window,document,\'script\',\'' . $gtm4wp_datalayer_name . '\',\'' . $one_gtm_code . '\');//]]>
|
929 |
</script>';
|
930 |
}
|
932 |
$_gtm_tag .= '
|
933 |
<!-- End Google Tag Manager -->';
|
934 |
|
935 |
+
$_gtm_tag = apply_filters( GTM4WP_WPFILTER_GETTHEGTMTAG, $_gtm_tag );
|
936 |
$_gtm_header_content .= $_gtm_tag;
|
937 |
}
|
938 |
|
939 |
$_gtm_header_content .= '
|
940 |
<!-- End Google Tag Manager for WordPress by gtm4wp.com -->';
|
941 |
|
942 |
+
if ( ! gtm4wp_amp_running() ) {
|
943 |
if ( $echo ) {
|
944 |
echo $_gtm_header_content;
|
945 |
} else {
|
961 |
}
|
962 |
|
963 |
function gtm4wp_wp_login() {
|
964 |
+
setcookie( 'gtm4wp_user_logged_in', '1', 0, '/' );
|
965 |
}
|
966 |
|
967 |
function gtm4wp_user_register() {
|
968 |
+
setcookie( 'gtm4wp_user_registered', '1', 0, '/' );
|
969 |
}
|
970 |
|
971 |
function gtm4wp_user_reg_login_script() {
|
972 |
global $gtp4wp_plugin_url;
|
973 |
|
974 |
+
$in_footer = apply_filters( 'gtm4wp_user_reg_login_script', true );
|
975 |
+
wp_enqueue_script( 'gtm4wp-user-reg-login-script', $gtp4wp_plugin_url . 'js/gtm4wp-users.js', array( 'jquery' ), GTM4WP_VERSION, $in_footer );
|
976 |
}
|
977 |
|
978 |
function gtm4wp_rocket_excluded_inline_js_content( $pattern ) {
|
979 |
+
$pattern[] = 'dataLayer';
|
980 |
+
$pattern[] = 'gtm4wp';
|
981 |
|
982 |
return $pattern;
|
983 |
}
|
984 |
|
985 |
+
add_action( 'wp_enqueue_scripts', 'gtm4wp_enqueue_scripts' );
|
986 |
$gtm4wp_header_begin_prior = 10;
|
987 |
+
if ( isset( $GLOBALS['gtm4wp_options'] ) && $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_LOADEARLY ] ) {
|
988 |
$gtm4wp_header_begin_prior = 2;
|
989 |
}
|
990 |
+
add_action( 'wp_head', 'gtm4wp_wp_header_begin', $gtm4wp_header_begin_prior, 0 );
|
991 |
+
add_action( 'wp_head', 'gtm4wp_wp_header_top', 1, 0 );
|
992 |
+
add_action( 'wp_footer', 'gtm4wp_wp_footer' );
|
993 |
+
add_action( 'wp_loaded', 'gtm4wp_wp_loaded' );
|
994 |
+
add_filter( 'body_class', 'gtm4wp_body_class', 10000 );
|
995 |
+
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, 'gtm4wp_add_basic_datalayer_data' );
|
996 |
|
997 |
// to be able to easily migrate from other Google Tag Manager plugins
|
998 |
+
add_action( 'body_open', 'gtm4wp_wp_body_open' );
|
999 |
|
1000 |
// compatibility with existing themes that natively support code injection after opening body tag
|
1001 |
+
add_action( 'genesis_before', 'gtm4wp_wp_body_open' ); // Genisis theme
|
1002 |
+
add_action( 'generate_before_header', 'gtm4wp_wp_body_open', 0 ); // GeneratePress theme
|
1003 |
+
add_action( 'elementor/page_templates/canvas/before_content', 'gtm4wp_wp_body_open' ); // Elementor
|
1004 |
+
|
1005 |
+
// standard WP theme support for body open tags
|
1006 |
+
add_action( 'wp_body_open', 'gtm4wp_wp_body_open' );
|
1007 |
+
|
1008 |
+
add_filter( 'rocket_excluded_inline_js_content', 'gtm4wp_rocket_excluded_inline_js_content' ); // WP Rocket
|
1009 |
+
if ( isset( $GLOBALS['gtm4wp_options'] ) && ( $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] || $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] )
|
1010 |
+
&& isset( $GLOBALS['woocommerce'] ) ) {
|
1011 |
+
require_once dirname( __FILE__ ) . '/../integration/woocommerce.php';
|
1012 |
}
|
1013 |
|
1014 |
+
if ( isset( $GLOBALS['gtm4wp_options'] ) && ( $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] != '' ) ) {
|
1015 |
+
require_once dirname( __FILE__ ) . '/../integration/google-optimize.php';
|
1016 |
}
|
1017 |
|
1018 |
+
if ( isset( $GLOBALS['gtm4wp_options'] ) && ( $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_EVENTS_USERLOGIN ] ) ) {
|
1019 |
+
add_action( 'wp_login', 'gtm4wp_wp_login' );
|
1020 |
+
add_action( 'wp_enqueue_scripts', 'gtm4wp_user_reg_login_script' );
|
1021 |
}
|
1022 |
|
1023 |
+
if ( isset( $GLOBALS['gtm4wp_options'] ) && ( $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_EVENTS_NEWUSERREG ] ) ) {
|
1024 |
+
add_action( 'user_register', 'gtm4wp_user_register' );
|
1025 |
+
add_action( 'wp_enqueue_scripts', 'gtm4wp_user_reg_login_script' );
|
1026 |
+
}
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
===
|
2 |
Contributors: duracelltomi
|
3 |
Donate link: https://gtm4wp.com/
|
4 |
Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, google ads, adwords remarketing, google ads remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel, google optimize, personalisation
|
5 |
Requires at least: 3.4.0
|
6 |
Requires PHP: 5.6
|
7 |
-
Tested up to: 5.
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl.html
|
11 |
|
@@ -130,9 +130,9 @@ Scroll tracking is based on the solution originally created by
|
|
130 |
Original script:
|
131 |
http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
|
132 |
|
133 |
-
= Google
|
134 |
|
135 |
-
Google Tag Manager for WordPress can add each dataLayer variable as
|
136 |
This enables you to build sophisticated remarketing lists.
|
137 |
|
138 |
= Blacklist & Whitelist Tag Manager tags and variables =
|
@@ -153,7 +153,7 @@ Google Tag Manager for WordPress integrates with several popular plugins. More i
|
|
153 |
* Classic e-commerce:
|
154 |
* fire an event when visitors add products to their cart
|
155 |
* capture transaction data to be passed to your ad platforms and/or Analytics
|
156 |
-
* capture necessary remarketing parameters for Google
|
157 |
* Enhanced e-commerce (beta):
|
158 |
* implementation of [Enhanced E-commerce](https://developers.google.com/tag-manager/enhanced-ecommerce)
|
159 |
* Does not support promotions since WooCommerce does not have such a feature (yet)
|
@@ -202,7 +202,7 @@ There are five dataLayer events you can use in your rule definitions:
|
|
202 |
* gtm4wp.reading.pagebottom: the visitor reached the end of the page. `timeToScroll` dataLayer variable updated
|
203 |
* gtm4wp.reading.readerType: based on time spent since article loaded we determine whether the user is a 'scanner' or 'reader' and store this in the `readerType` dataLayer variable
|
204 |
|
205 |
-
Example use cases: using these events as triggers, you can fire Google Universal Analytics and/or
|
206 |
to report micro conversions and/or to serve ads only to visitors who spend more time reading your content.
|
207 |
|
208 |
= Can I exclude certain user roles from being tracked? =
|
@@ -258,6 +258,22 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
|
|
258 |
|
259 |
== Changelog ==
|
260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
= 1.9.2 =
|
262 |
|
263 |
* Fixed: possible PHP warning if geo data or weather data feature is turned on
|
@@ -348,8 +364,8 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
|
|
348 |
* Fixed: even more WooCommerce 3.x compatibility
|
349 |
* Added: registration date of the logged in user can be added to the data layer
|
350 |
* Updated: geoplugin.net has been replaced by freegeoip.net for weather tracking which has far better quota for free usage
|
351 |
-
* Updated:
|
352 |
-
* Updated: Selecting a product variation will include the price of the product in
|
353 |
* Updated: minor code cleanup
|
354 |
|
355 |
= 1.7.1 =
|
@@ -438,7 +454,7 @@ Major changes to the Enhanced Ecommerce implementation of the WooCommerce integr
|
|
438 |
* Fixed: opening product detail page in a new window/tab when user pressed the CTRL key
|
439 |
* Fixed: ecomm_totalvalue included the total price of the cart without taxes
|
440 |
* Fixed: ecomm_totalvalue does not take into account the quantity of ordered products on the order received page
|
441 |
-
* Fixed: php error message on product lists when
|
442 |
* Fixed: added data-cfasync="false" to the GTM container code for better compatibility with CloudFlare
|
443 |
* Added: introducing tracking of list names (general product list, recent products list, featured products list, etc.)
|
444 |
* Some list names (like cross-sells) will be shown as 'General Product List'. A proposed change in WooCommerce 2.6 will solve that issue
|
@@ -467,7 +483,7 @@ Major changes to the Enhanced Ecommerce implementation of the WooCommerce integr
|
|
467 |
= 1.1 =
|
468 |
|
469 |
* Added: track embedded YouTube/Vimeo/Soundcloud videos (experimental)
|
470 |
-
* Added: new checkbox - use product SKU for
|
471 |
* Added: place your container code after the opening body tag without modifying your theme files (thx Yaniv Friedensohn)
|
472 |
* Added: automatic codeless container code injection for Genesis framework users
|
473 |
* Fixed: Possible PHP error with custom payment gateway (QuickPay) on the checkout page (thx Damiel for findig this)
|
@@ -581,6 +597,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
|
|
581 |
|
582 |
== Upgrade Notice ==
|
583 |
|
|
|
|
|
|
|
|
|
584 |
= 1.9.2 =
|
585 |
|
586 |
Fixed possible PHP warning if geo data or weather data feature is turned on
|
@@ -710,7 +730,7 @@ Important change: Tag Manager event name of a WooCommerce successful order has b
|
|
710 |
See changelog for details.
|
711 |
|
712 |
= 0.3 =
|
713 |
-
This is a minor release. If you are using WooCommerce you should update to include more accurate
|
714 |
|
715 |
= 0.2 =
|
716 |
BACKWARD INCOMPATIBLE CHANGE: Names of Tag Manager click events has been changed to comply with naming conventions.
|
1 |
+
=== Google Tag Manager for WordPress ===
|
2 |
Contributors: duracelltomi
|
3 |
Donate link: https://gtm4wp.com/
|
4 |
Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, google ads, adwords remarketing, google ads remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel, google optimize, personalisation
|
5 |
Requires at least: 3.4.0
|
6 |
Requires PHP: 5.6
|
7 |
+
Tested up to: 5.2.2
|
8 |
+
Stable tag: 1.10
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl.html
|
11 |
|
130 |
Original script:
|
131 |
http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
|
132 |
|
133 |
+
= Google Ads remarketing =
|
134 |
|
135 |
+
Google Tag Manager for WordPress can add each dataLayer variable as a Google Ads remarketing custom parameter list.
|
136 |
This enables you to build sophisticated remarketing lists.
|
137 |
|
138 |
= Blacklist & Whitelist Tag Manager tags and variables =
|
153 |
* Classic e-commerce:
|
154 |
* fire an event when visitors add products to their cart
|
155 |
* capture transaction data to be passed to your ad platforms and/or Analytics
|
156 |
+
* capture necessary remarketing parameters for Google Ads Dynamic Remarketing
|
157 |
* Enhanced e-commerce (beta):
|
158 |
* implementation of [Enhanced E-commerce](https://developers.google.com/tag-manager/enhanced-ecommerce)
|
159 |
* Does not support promotions since WooCommerce does not have such a feature (yet)
|
202 |
* gtm4wp.reading.pagebottom: the visitor reached the end of the page. `timeToScroll` dataLayer variable updated
|
203 |
* gtm4wp.reading.readerType: based on time spent since article loaded we determine whether the user is a 'scanner' or 'reader' and store this in the `readerType` dataLayer variable
|
204 |
|
205 |
+
Example use cases: using these events as triggers, you can fire Google Universal Analytics and/or Google Ads remarketing/conversion tags
|
206 |
to report micro conversions and/or to serve ads only to visitors who spend more time reading your content.
|
207 |
|
208 |
= Can I exclude certain user roles from being tracked? =
|
258 |
|
259 |
== Changelog ==
|
260 |
|
261 |
+
= 1.10 =
|
262 |
+
|
263 |
+
* Added: Automatically add the noscript part of the container code after the opening body tag for WordPress 5.2+ sites where themes support the new wp_body_open action
|
264 |
+
* Added: add associated taxonomy values for post type
|
265 |
+
* Added: select brand taxonomy for WooCommerce products to populate "Product brand" dimension in enhanced ecommerce
|
266 |
+
* Added: add cart content into data layer so that you can personalize your site experience using Google Optimize
|
267 |
+
* Added: option to remove shipping costs from revenue data on order received page of WooCommerce
|
268 |
+
* Added: if you enable either enhanced ecommerce or just Google Ads remarketing variables, 3 new data layer variables will be also available about the product on a detail page
|
269 |
+
* Product rating details (productRatingCounts)
|
270 |
+
* Averate product rating (productAverageRating)
|
271 |
+
* Review count (productReviewCount)
|
272 |
+
* Added: if you are using Cloudflare, you can now add the country code HTTP header value into the data layer and read from it with the geoCloudflareCountryCode variable name
|
273 |
+
* Fixed: better compatibility with Google's mod_pagespeed
|
274 |
+
* Fixed: missing product quantity while adding a variable product into the cart
|
275 |
+
* Fixed: prevent multiple tracking of WooCommerce orders on mobile devices where the mobile browser reloads the order received page from local cache executing GTM tracking again
|
276 |
+
|
277 |
= 1.9.2 =
|
278 |
|
279 |
* Fixed: possible PHP warning if geo data or weather data feature is turned on
|
364 |
* Fixed: even more WooCommerce 3.x compatibility
|
365 |
* Added: registration date of the logged in user can be added to the data layer
|
366 |
* Updated: geoplugin.net has been replaced by freegeoip.net for weather tracking which has far better quota for free usage
|
367 |
+
* Updated: Google Ads dynamic remarketing data layer items on a WooCommerce product page will be shown for the root product as well on variable product pages
|
368 |
+
* Updated: Selecting a product variation will include the price of the product in Google Ads dynamic remarketing data layer items
|
369 |
* Updated: minor code cleanup
|
370 |
|
371 |
= 1.7.1 =
|
454 |
* Fixed: opening product detail page in a new window/tab when user pressed the CTRL key
|
455 |
* Fixed: ecomm_totalvalue included the total price of the cart without taxes
|
456 |
* Fixed: ecomm_totalvalue does not take into account the quantity of ordered products on the order received page
|
457 |
+
* Fixed: php error message on product lists when Google Ads dynamic remarketing was enabled on WooCommerce 2.6
|
458 |
* Fixed: added data-cfasync="false" to the GTM container code for better compatibility with CloudFlare
|
459 |
* Added: introducing tracking of list names (general product list, recent products list, featured products list, etc.)
|
460 |
* Some list names (like cross-sells) will be shown as 'General Product List'. A proposed change in WooCommerce 2.6 will solve that issue
|
483 |
= 1.1 =
|
484 |
|
485 |
* Added: track embedded YouTube/Vimeo/Soundcloud videos (experimental)
|
486 |
+
* Added: new checkbox - use product SKU for Google Ads Dynamic Remarketing variables instead of product ID (experimental)
|
487 |
* Added: place your container code after the opening body tag without modifying your theme files (thx Yaniv Friedensohn)
|
488 |
* Added: automatic codeless container code injection for Genesis framework users
|
489 |
* Fixed: Possible PHP error with custom payment gateway (QuickPay) on the checkout page (thx Damiel for findig this)
|
597 |
|
598 |
== Upgrade Notice ==
|
599 |
|
600 |
+
= 1.10 =
|
601 |
+
|
602 |
+
Better WordPress 5.2 integration, support for brands in WooCommerce, access cart content in data layer, more stable double transaction tracking prevention on mobiles and more!
|
603 |
+
|
604 |
= 1.9.2 =
|
605 |
|
606 |
Fixed possible PHP warning if geo data or weather data feature is turned on
|
730 |
See changelog for details.
|
731 |
|
732 |
= 0.3 =
|
733 |
+
This is a minor release. If you are using WooCommerce you should update to include more accurate Google Ads dynamic remarketing feature.
|
734 |
|
735 |
= 0.2 =
|
736 |
BACKWARD INCOMPATIBLE CHANGE: Names of Tag Manager click events has been changed to comply with naming conventions.
|
uninstall.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
// if uninstall.php is not called by WordPress, die
|
3 |
-
if ( !defined( 'WP_UNINSTALL_PLUGIN' )) {
|
4 |
die;
|
5 |
}
|
6 |
|
7 |
-
require_once
|
8 |
|
9 |
-
delete_option( GTM4WP_OPTIONS );
|
1 |
<?php
|
2 |
// if uninstall.php is not called by WordPress, die
|
3 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
4 |
die;
|
5 |
}
|
6 |
|
7 |
+
require_once dirname( __FILE__ ) . '/common/readoptions.php';
|
8 |
|
9 |
+
delete_option( GTM4WP_OPTIONS );
|