Version Description
- Added: initial support for AMP plugin from Automattic (thx koconder for the contribution!)
- Added: option to remove tax from revenue data on order received page of WooCommerce
- Added: WooCommerce enhanced ecommerce datasets now include stock levels
- Added: new productIsVariable data layer variable is set to 1 on variable WooCommerce product pages
- Added: product impressions can now be split into multiple chunks to prevent data loss on large product category and site home pages (thx Tim Zook for the contribution!)
- IMPORTANT! You will need to update your GTM setup, please read the new Step 9 section of the setup tutorial page.
- Added: you can now disable flagging of WooCommerce orders as being already tracked once. In same cases (with iDeal for example) you may need this to make purchase tracking to work.
- Added: uninstalling the plugin will now remove configured plugin options from database
- Added: new advanced plugin option: data layer variable visitorDoNotTrack will include 1 if the user has set the do not track flag in his/her browser
- Added: new data layer event when a user has logged in on the frontend: gtm4wp.userLoggedIn
- Added: new data layer event when a new user has registered on the frontend: gtm4wp.userRegistered
- Added: new advanced plugin option: move data layer declaration and Google Tag Manager container as close as possible to the beginning of the HTML document
- Added: better WP Rocket support
- Updated: Full Google Optimize support. Now the plugin can load your Google Optimize container with the recommended code placement
- Updated: moved most of the inline JavaScript codes into separate .js files which should help cache plugins to do their job much better when my plugin is active
- Fixed: wrong ecomm_pagetype on product search result pages
- Fixed: PHP notice in some cases when geo data was not loaded properly
- Fixed / Added: freegeoip.net was rebranded to ipstack.com and an API key is needed now even for free usage. You can now add your API key so that weather data and geo data can be added into the data layer
- Warning: some plugin features will be remove from v1.10, most of them can be tracked now using pure Google Tag Manager triggers:
- Social actions
- Outbound link click events
- Download click events
- Email click events
- Warning: PHP 5.6 is now the minimum recommended version to use this plugin. I advise to move to PHP 7.x
Download this release
Release Info
Developer | duracelltomi |
Plugin | DuracellTomi's Google Tag Manager for WordPress |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.1 to 1.9
- admin/admin.php +1518 -1344
- common/readoptions.php +269 -244
- css/admin-gtm4wp.css +12 -12
- duracelltomi-google-tag-manager-for-wordpress.php +31 -31
- integration/amp.php +152 -0
- integration/google-optimize.php +61 -28
- integration/soundcloud.php +6 -33
- integration/vimeo.php +7 -28
- integration/woocommerce.php +1390 -1304
- integration/youtube.php +15 -15
- js/admin-subtabs.js +81 -77
- js/admin-tabcreator.js +80 -80
- js/analytics-talk-content-tracking.js +138 -138
- js/froogaloop.js +259 -259
- js/gtm4wp-contact-form-7-tracker.js +24 -24
- js/gtm4wp-download-tracker.js +14 -14
- js/gtm4wp-email-link-tracker.js +12 -12
- js/gtm4wp-form-move-tracker.js +50 -50
- js/gtm4wp-outbound-click-tracker.js +19 -19
- js/gtm4wp-social-tracker.js +107 -97
- js/gtm4wp-soundcloud.js +137 -138
- js/gtm4wp-users.js +39 -0
- js/gtm4wp-vimeo-froogaloop.js +105 -105
- js/gtm4wp-vimeo.js +268 -268
- js/gtm4wp-woocommerce-classic.js +26 -15
- js/gtm4wp-woocommerce-enhanced.js +570 -126
- js/gtm4wp-youtube.js +221 -221
- public/frontend.php +897 -785
- readme.txt +43 -9
- uninstall.php +9 -0
admin/admin.php
CHANGED
@@ -1,1344 +1,1518 @@
|
|
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 |
-
|
9 |
-
|
10 |
-
|
11 |
-
define( '
|
12 |
-
define( '
|
13 |
-
define( '
|
14 |
-
define( '
|
15 |
-
|
16 |
-
define( '
|
17 |
-
|
18 |
-
define( '
|
19 |
-
|
20 |
-
define( '
|
21 |
-
|
22 |
-
define( '
|
23 |
-
define( '
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
"
|
29 |
-
"
|
30 |
-
"
|
31 |
-
"
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
"
|
38 |
-
"
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
"
|
43 |
-
"
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
"
|
48 |
-
"
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
"
|
53 |
-
"
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
"
|
58 |
-
"
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
"
|
63 |
-
"
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
"
|
68 |
-
"
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
"
|
73 |
-
"
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
"
|
78 |
-
"
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
"
|
83 |
-
"
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
"
|
88 |
-
"
|
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 |
-
|
170 |
-
|
171 |
-
|
172 |
-
"
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
)
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
"label" => __( "
|
181 |
-
"description" => __(
|
182 |
-
"phase" => GTM4WP_PHASE_STABLE
|
183 |
-
),
|
184 |
-
|
185 |
-
"label" => __( "
|
186 |
-
"description" => __(
|
187 |
-
"phase" => GTM4WP_PHASE_STABLE
|
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 |
-
"
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
)
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
"label" => __( "
|
229 |
-
"description" => __( "
|
230 |
-
"phase" =>
|
231 |
-
),
|
232 |
-
|
233 |
-
"label" => __( "
|
234 |
-
"description" => __( "
|
235 |
-
"phase" =>
|
236 |
-
),
|
237 |
-
|
238 |
-
"label" => __( "
|
239 |
-
"description" => __( "Enter
|
240 |
-
"phase" =>
|
241 |
-
),
|
242 |
-
|
243 |
-
"label" => __( "
|
244 |
-
"description" => __( "
|
245 |
-
"phase" =>
|
246 |
-
)
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
"
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
)
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
"label"
|
262 |
-
"description"
|
263 |
-
"phase" => GTM4WP_PHASE_STABLE
|
264 |
-
),
|
265 |
-
|
266 |
-
"label"
|
267 |
-
"description"
|
268 |
-
"phase" => GTM4WP_PHASE_STABLE
|
269 |
-
),
|
270 |
-
|
271 |
-
"label"
|
272 |
-
"description"
|
273 |
-
"phase" => GTM4WP_PHASE_STABLE
|
274 |
-
),
|
275 |
-
|
276 |
-
"label"
|
277 |
-
"description"
|
278 |
-
"phase" => GTM4WP_PHASE_STABLE
|
279 |
-
)
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
"
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
"
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
"
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
"
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
"
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
"
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
"
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
"
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
"
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
"
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
"
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
"
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
"
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
"
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
"
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
)
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
"label" => __( "
|
365 |
-
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
366 |
-
"phase" => GTM4WP_PHASE_STABLE
|
367 |
-
),
|
368 |
-
|
369 |
-
"label" => __( "
|
370 |
-
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
371 |
-
"phase" => GTM4WP_PHASE_STABLE
|
372 |
-
),
|
373 |
-
|
374 |
-
"label" => __( "
|
375 |
-
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
376 |
-
"phase" => GTM4WP_PHASE_STABLE
|
377 |
-
),
|
378 |
-
|
379 |
-
"label" => __( "
|
380 |
-
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
381 |
-
"phase" => GTM4WP_PHASE_STABLE
|
382 |
-
)
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
"
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
"
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
"
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
"
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
"
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
"
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
)
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
"label" => __( "
|
423 |
-
"description" => __( "
|
424 |
-
"phase" => GTM4WP_PHASE_STABLE
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
"
|
429 |
-
"
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
"
|
435 |
-
|
436 |
-
|
437 |
-
"
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
"
|
447 |
-
"
|
448 |
-
"
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
"
|
453 |
-
"
|
454 |
-
"
|
455 |
-
|
456 |
-
|
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 |
-
|
482 |
-
|
483 |
-
"
|
484 |
-
"
|
485 |
-
|
486 |
-
|
487 |
-
)
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
"
|
494 |
-
|
495 |
-
|
496 |
-
"
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
"
|
502 |
-
"
|
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 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
echo '<
|
623 |
-
|
624 |
-
echo '<
|
625 |
-
|
626 |
-
|
627 |
-
break;
|
628 |
-
}
|
629 |
-
|
630 |
-
case
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
$
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
$
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
}
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
)
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
)
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
);
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
"
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
"
|
1094 |
-
"
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_SEARCHDATA => array(
|
86 |
+
"label" => __( "Search data", 'duracelltomi-google-tag-manager' ),
|
87 |
+
"description" => __( "Check this option to include the search term, referring page URL and number of results on the search page.", 'duracelltomi-google-tag-manager' ),
|
88 |
+
"phase" => GTM4WP_PHASE_STABLE
|
89 |
+
),
|
90 |
+
GTM4WP_OPTION_INCLUDE_LOGGEDIN => array(
|
91 |
+
"label" => __( "Logged in status", 'duracelltomi-google-tag-manager' ),
|
92 |
+
"description" => __( "Check this option to include whether there is a logged in user on your website.", 'duracelltomi-google-tag-manager' ),
|
93 |
+
"phase" => GTM4WP_PHASE_STABLE
|
94 |
+
),
|
95 |
+
GTM4WP_OPTION_INCLUDE_USERROLE => array(
|
96 |
+
"label" => __( "Logged in user role", 'duracelltomi-google-tag-manager' ),
|
97 |
+
"description" => __( "Check this option to include the role of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
98 |
+
"phase" => GTM4WP_PHASE_STABLE
|
99 |
+
),
|
100 |
+
GTM4WP_OPTION_INCLUDE_USERID => array(
|
101 |
+
"label" => __( "Logged in user ID", 'duracelltomi-google-tag-manager' ),
|
102 |
+
"description" => __( "Check this option to include the ID of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
103 |
+
"phase" => GTM4WP_PHASE_STABLE
|
104 |
+
),
|
105 |
+
GTM4WP_OPTION_INCLUDE_USERNAME => array(
|
106 |
+
"label" => __( "Logged in user name", 'duracelltomi-google-tag-manager' ),
|
107 |
+
"description" => __( "Check this option to include the username of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
108 |
+
"phase" => GTM4WP_PHASE_STABLE
|
109 |
+
),
|
110 |
+
GTM4WP_OPTION_INCLUDE_USEREMAIL => array(
|
111 |
+
"label" => __( "Logged in user email", 'duracelltomi-google-tag-manager' ),
|
112 |
+
"description" => __( "Check this option to include the email address of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
113 |
+
"phase" => GTM4WP_PHASE_STABLE
|
114 |
+
),
|
115 |
+
GTM4WP_OPTION_INCLUDE_USERREGDATE => array(
|
116 |
+
"label" => __( "Logged in user creation date", 'duracelltomi-google-tag-manager' ),
|
117 |
+
"description" => __( "Check this option to include the date of creation (registration) of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
118 |
+
"phase" => GTM4WP_PHASE_STABLE
|
119 |
+
),
|
120 |
+
GTM4WP_OPTION_INCLUDE_VISITOR_IP => array(
|
121 |
+
"label" => __( "Visitor IP", 'duracelltomi-google-tag-manager' ),
|
122 |
+
"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' ),
|
123 |
+
"phase" => GTM4WP_PHASE_STABLE
|
124 |
+
),
|
125 |
+
GTM4WP_OPTION_INCLUDE_REMARKETING => array(
|
126 |
+
"label" => __( "Remarketing variable", 'duracelltomi-google-tag-manager' ),
|
127 |
+
"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' ),
|
128 |
+
"phase" => GTM4WP_PHASE_STABLE
|
129 |
+
),
|
130 |
+
GTM4WP_OPTION_INCLUDE_BROWSERDATA => array(
|
131 |
+
"label" => __( "Browser data *", 'duracelltomi-google-tag-manager' ),
|
132 |
+
"description" => __( "Check this option to include the name, version and engine data of the browser the visitor uses.", 'duracelltomi-google-tag-manager' ),
|
133 |
+
"phase" => GTM4WP_PHASE_BETA
|
134 |
+
),
|
135 |
+
GTM4WP_OPTION_INCLUDE_OSDATA => array(
|
136 |
+
"label" => __( "OS data *", 'duracelltomi-google-tag-manager' ),
|
137 |
+
"description" => __( "Check this option to include the name and version of the operating system the visitor uses.", 'duracelltomi-google-tag-manager' ),
|
138 |
+
"phase" => GTM4WP_PHASE_BETA
|
139 |
+
),
|
140 |
+
GTM4WP_OPTION_INCLUDE_DEVICEDATA => array(
|
141 |
+
"label" => __( "Device data *", 'duracelltomi-google-tag-manager' ),
|
142 |
+
"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' ),
|
143 |
+
"phase" => GTM4WP_PHASE_BETA
|
144 |
+
),
|
145 |
+
GTM4WP_OPTION_INCLUDE_MISCGEO => array(
|
146 |
+
"label" => __( "Geo data", 'duracelltomi-google-tag-manager' ),
|
147 |
+
"description" => __( 'Add geo data (latitude, longitude, country, city, etc) of the current visitor (provided by ipstack.com)', 'duracelltomi-google-tag-manager' ),
|
148 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
149 |
+
),
|
150 |
+
GTM4WP_OPTION_INCLUDE_MISCGEOAPI => array(
|
151 |
+
"label" => __( "IPStack.com API key", 'duracelltomi-google-tag-manager' ),
|
152 |
+
"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" ),
|
153 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
154 |
+
),
|
155 |
+
GTM4WP_OPTION_INCLUDE_WEATHER => array(
|
156 |
+
"label" => __( "Weather data", 'duracelltomi-google-tag-manager' ),
|
157 |
+
"description" => sprintf( __( "Check this option to include the current weather conditions around the current visitor.<br /><br />".
|
158 |
+
"<strong>Attention!</strong> This feature uses <a href=\"%s\" target=\"_blank\">ipstack.com</a> and ".
|
159 |
+
"<a href=\"%s\" target=\"_blank\">openweathermap.org</a> to collect data.<br />".
|
160 |
+
"Depending on your website's traffic, additional fees may apply!<br />".
|
161 |
+
"This plugin caches weather data for 1 hour to lower the need to access those services.<br /><br />".
|
162 |
+
"If you activate weather data, <strong>you will need</strong> to add an IPStack.com API key regardless of whether you ".
|
163 |
+
"activate the 'Geo data' option!", 'duracelltomi-google-tag-manager' ),
|
164 |
+
"https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress",
|
165 |
+
"http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress"
|
166 |
+
),
|
167 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
168 |
+
),
|
169 |
+
GTM4WP_OPTION_INCLUDE_WEATHERUNITS => array(
|
170 |
+
"label" => __( "Weather data units", 'duracelltomi-google-tag-manager' ),
|
171 |
+
"description" => __( "Select which temperature units you would like to use.", 'duracelltomi-google-tag-manager' ),
|
172 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
173 |
+
),
|
174 |
+
GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => array(
|
175 |
+
"label" => __( "OpenWeatherMap API key", 'duracelltomi-google-tag-manager' ),
|
176 |
+
"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" ),
|
177 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
178 |
+
),
|
179 |
+
GTM4WP_OPTION_INCLUDE_SITEID => array(
|
180 |
+
"label" => __( "Site ID", 'duracelltomi-google-tag-manager' ),
|
181 |
+
"description" => __( 'ID of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
|
182 |
+
"phase" => GTM4WP_PHASE_STABLE
|
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["gtm4wp_eventfieldtexts"] = array(
|
192 |
+
GTM4WP_OPTION_EVENTS_FORMMOVE => array(
|
193 |
+
"label" => __( "Form fill events (gtm4wp.formElementEnter & gtm4wp.formElementLeave)", 'duracelltomi-google-tag-manager' ),
|
194 |
+
"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' ),
|
195 |
+
"phase" => GTM4WP_PHASE_STABLE
|
196 |
+
),
|
197 |
+
GTM4WP_OPTION_EVENTS_NEWUSERREG => array(
|
198 |
+
"label" => __( "New user registration", 'duracelltomi-google-tag-manager' ),
|
199 |
+
"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' ),
|
200 |
+
"phase" => GTM4WP_PHASE_STABLE
|
201 |
+
),
|
202 |
+
GTM4WP_OPTION_EVENTS_USERLOGIN => array(
|
203 |
+
"label" => __( "User logged in", 'duracelltomi-google-tag-manager' ),
|
204 |
+
"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' ),
|
205 |
+
"phase" => GTM4WP_PHASE_STABLE
|
206 |
+
),
|
207 |
+
GTM4WP_OPTION_EVENTS_YOUTUBE => array(
|
208 |
+
"label" => __( "YouTube video events", 'duracelltomi-google-tag-manager' ),
|
209 |
+
"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' ),
|
210 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
211 |
+
),
|
212 |
+
GTM4WP_OPTION_EVENTS_VIMEO => array(
|
213 |
+
"label" => __( "Vimeo video events", 'duracelltomi-google-tag-manager' ),
|
214 |
+
"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' ),
|
215 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
216 |
+
),
|
217 |
+
GTM4WP_OPTION_EVENTS_SOUNDCLOUD => array(
|
218 |
+
"label" => __( "Soundcloud events", 'duracelltomi-google-tag-manager' ),
|
219 |
+
"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' ),
|
220 |
+
"phase" => GTM4WP_PHASE_EXPERIMENTAL
|
221 |
+
),
|
222 |
+
GTM4WP_OPTION_EVENTS_SOCIAL => array(
|
223 |
+
"label" => __( "Social actions (gtm4wp.socialAction)", 'duracelltomi-google-tag-manager' ),
|
224 |
+
"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' ),
|
225 |
+
"phase" => GTM4WP_PHASE_DEPRECATED
|
226 |
+
),
|
227 |
+
GTM4WP_OPTION_EVENTS_OUTBOUND => array(
|
228 |
+
"label" => __( "Outbound link click events (gtm4wp.outboundClick)", 'duracelltomi-google-tag-manager' ),
|
229 |
+
"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' ),
|
230 |
+
"phase" => GTM4WP_PHASE_DEPRECATED
|
231 |
+
),
|
232 |
+
GTM4WP_OPTION_EVENTS_DOWNLOADS => array(
|
233 |
+
"label" => __( "Download click events (gtm4wp.downloadClick)", 'duracelltomi-google-tag-manager' ),
|
234 |
+
"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' ),
|
235 |
+
"phase" => GTM4WP_PHASE_DEPRECATED
|
236 |
+
),
|
237 |
+
GTM4WP_OPTION_EVENTS_DWLEXT => array(
|
238 |
+
"label" => __( "Extensions to track", 'duracelltomi-google-tag-manager' ),
|
239 |
+
"description" => __( "Enter a comma separated list of extensions to track when 'Include download click events' option is set.", 'duracelltomi-google-tag-manager' ),
|
240 |
+
"phase" => GTM4WP_PHASE_DEPRECATED
|
241 |
+
),
|
242 |
+
GTM4WP_OPTION_EVENTS_EMAILCLICKS => array(
|
243 |
+
"label" => __( "Email click events (gtm4wp.emailClick)", 'duracelltomi-google-tag-manager' ),
|
244 |
+
"description" => __( "Check this option to include a Tag Manager event when a visitor clicks on an email link.", 'duracelltomi-google-tag-manager' ),
|
245 |
+
"phase" => GTM4WP_PHASE_DEPRECATED
|
246 |
+
)
|
247 |
+
);
|
248 |
+
|
249 |
+
$GLOBALS["gtm4wp_scrollerfieldtexts"] = array(
|
250 |
+
GTM4WP_OPTION_SCROLLER_ENABLED => array(
|
251 |
+
"label" => __( "Enabled", 'duracelltomi-google-tag-manager' ),
|
252 |
+
"description" => __( "Enable scroll tracker script on your website.", 'duracelltomi-google-tag-manager' ),
|
253 |
+
"phase" => GTM4WP_PHASE_STABLE
|
254 |
+
),
|
255 |
+
GTM4WP_OPTION_SCROLLER_DEBUGMODE => array(
|
256 |
+
"label" => __( "Debug mode", 'duracelltomi-google-tag-manager' ),
|
257 |
+
"description" => __( "Fire console.log() commands instead of dataLayer events.", 'duracelltomi-google-tag-manager' ),
|
258 |
+
"phase" => GTM4WP_PHASE_STABLE
|
259 |
+
),
|
260 |
+
GTM4WP_OPTION_SCROLLER_CALLBACKTIME => array(
|
261 |
+
"label" => __( "Time delay before location check", 'duracelltomi-google-tag-manager' ),
|
262 |
+
"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' ),
|
263 |
+
"phase" => GTM4WP_PHASE_STABLE
|
264 |
+
),
|
265 |
+
GTM4WP_OPTION_SCROLLER_DISTANCE => array(
|
266 |
+
"label" => __( "Minimum distance", 'duracelltomi-google-tag-manager' ),
|
267 |
+
"description" => __( "The minimum amount of pixels that a visitor has to scroll before we treat the move as scrolling.", 'duracelltomi-google-tag-manager' ),
|
268 |
+
"phase" => GTM4WP_PHASE_STABLE
|
269 |
+
),
|
270 |
+
GTM4WP_OPTION_SCROLLER_CONTENTID => array(
|
271 |
+
"label" => __( "Content ID", 'duracelltomi-google-tag-manager' ),
|
272 |
+
"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' ),
|
273 |
+
"phase" => GTM4WP_PHASE_STABLE
|
274 |
+
),
|
275 |
+
GTM4WP_OPTION_SCROLLER_READERTIME => array(
|
276 |
+
"label" => __( "Scroller time", 'duracelltomi-google-tag-manager' ),
|
277 |
+
"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' ),
|
278 |
+
"phase" => GTM4WP_PHASE_STABLE
|
279 |
+
)
|
280 |
+
);
|
281 |
+
|
282 |
+
$GLOBALS["gtm4wp_blacklistfieldtexts"] = array(
|
283 |
+
GTM4WP_OPTION_BLACKLIST_ENABLE => array(
|
284 |
+
"label" => __( "Enable blacklist/whitelist", 'duracelltomi-google-tag-manager' ),
|
285 |
+
"description" => __( "Disable feature or select whether you want to whitelist or blacklist tags", 'duracelltomi-google-tag-manager' ),
|
286 |
+
"phase" => GTM4WP_PHASE_STABLE
|
287 |
+
),
|
288 |
+
GTM4WP_OPTION_BLACKLIST_AWCONV => array(
|
289 |
+
"label" => __( "AdWords Conversion Tracking Tag", 'duracelltomi-google-tag-manager' ),
|
290 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
291 |
+
"phase" => GTM4WP_PHASE_STABLE
|
292 |
+
),
|
293 |
+
GTM4WP_OPTION_BLACKLIST_AWREMARKET => array(
|
294 |
+
"label" => __( "AdWords Remarketing Tag", 'duracelltomi-google-tag-manager' ),
|
295 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
296 |
+
"phase" => GTM4WP_PHASE_STABLE
|
297 |
+
),
|
298 |
+
GTM4WP_OPTION_BLACKLIST_GACLASSIC => array(
|
299 |
+
"label" => __( "Google Analytics Tag", 'duracelltomi-google-tag-manager' ),
|
300 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
301 |
+
"phase" => GTM4WP_PHASE_STABLE
|
302 |
+
),
|
303 |
+
GTM4WP_OPTION_BLACKLIST_UA => array(
|
304 |
+
"label" => __( "Universal Analytics Tag", 'duracelltomi-google-tag-manager' ),
|
305 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
306 |
+
"phase" => GTM4WP_PHASE_STABLE
|
307 |
+
),
|
308 |
+
GTM4WP_OPTION_BLACKLIST_ADADVISOR => array(
|
309 |
+
"label" => __( "AdAdvisor Tag", 'duracelltomi-google-tag-manager' ),
|
310 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
311 |
+
"phase" => GTM4WP_PHASE_STABLE
|
312 |
+
),
|
313 |
+
GTM4WP_OPTION_BLACKLIST_ADROLL => array(
|
314 |
+
"label" => __( "AdRoll Smart Pixel Tag", 'duracelltomi-google-tag-manager' ),
|
315 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
316 |
+
"phase" => GTM4WP_PHASE_STABLE
|
317 |
+
),
|
318 |
+
GTM4WP_OPTION_BLACKLIST_BIZO => array(
|
319 |
+
"label" => __( "Bizo Insight Tag", 'duracelltomi-google-tag-manager' ),
|
320 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
321 |
+
"phase" => GTM4WP_PHASE_STABLE
|
322 |
+
),
|
323 |
+
GTM4WP_OPTION_BLACKLIST_CLICKTALE => array(
|
324 |
+
"label" => __( "ClickTale Standard Tracking Tag", 'duracelltomi-google-tag-manager' ),
|
325 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
326 |
+
"phase" => GTM4WP_PHASE_STABLE
|
327 |
+
),
|
328 |
+
GTM4WP_OPTION_BLACKLIST_COMSCORE => array(
|
329 |
+
"label" => __( "comScore Unified Digital Measurement Tag", 'duracelltomi-google-tag-manager' ),
|
330 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
331 |
+
"phase" => GTM4WP_PHASE_STABLE
|
332 |
+
),
|
333 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMHTML => array(
|
334 |
+
"label" => __( "Custom HTML Tag", 'duracelltomi-google-tag-manager' ),
|
335 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
336 |
+
"phase" => GTM4WP_PHASE_STABLE
|
337 |
+
),
|
338 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMIMG => array(
|
339 |
+
"label" => __( "Custom Image Tag", 'duracelltomi-google-tag-manager' ),
|
340 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
341 |
+
"phase" => GTM4WP_PHASE_STABLE
|
342 |
+
),
|
343 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT => array(
|
344 |
+
"label" => __( "DoubleClick Floodlight Counter Tag", 'duracelltomi-google-tag-manager' ),
|
345 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
346 |
+
"phase" => GTM4WP_PHASE_STABLE
|
347 |
+
),
|
348 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKSALES => array(
|
349 |
+
"label" => __( "DoubleClick Floodlight Sales Tag", 'duracelltomi-google-tag-manager' ),
|
350 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
351 |
+
"phase" => GTM4WP_PHASE_STABLE
|
352 |
+
),
|
353 |
+
GTM4WP_OPTION_BLACKLIST_MARIN => array(
|
354 |
+
"label" => __( "Marin Software Tag", 'duracelltomi-google-tag-manager' ),
|
355 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
356 |
+
"phase" => GTM4WP_PHASE_STABLE
|
357 |
+
),
|
358 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME => array(
|
359 |
+
"label" => __( "Mediaplex - IFRAME MCT Tag", 'duracelltomi-google-tag-manager' ),
|
360 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
361 |
+
"phase" => GTM4WP_PHASE_STABLE
|
362 |
+
),
|
363 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXROI => array(
|
364 |
+
"label" => __( "Mediaplex - Standard IMG ROI Tag", 'duracelltomi-google-tag-manager' ),
|
365 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
366 |
+
"phase" => GTM4WP_PHASE_STABLE
|
367 |
+
),
|
368 |
+
GTM4WP_OPTION_BLACKLIST_MEDIA6DEG => array(
|
369 |
+
"label" => __( "Media6Degrees Universal Pixel Tag", 'duracelltomi-google-tag-manager' ),
|
370 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
371 |
+
"phase" => GTM4WP_PHASE_STABLE
|
372 |
+
),
|
373 |
+
GTM4WP_OPTION_BLACKLIST_TURNCONV => array(
|
374 |
+
"label" => __( "Turn Conversion Tracking Tag", 'duracelltomi-google-tag-manager' ),
|
375 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
376 |
+
"phase" => GTM4WP_PHASE_STABLE
|
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["gtm4wp_blacklistmfieldtexts"] = array(
|
386 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT => array(
|
387 |
+
"label" => __( "DOM element Macro", 'duracelltomi-google-tag-manager' ),
|
388 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
389 |
+
"phase" => GTM4WP_PHASE_STABLE
|
390 |
+
),
|
391 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS => array(
|
392 |
+
"label" => __( "Custom JavaScript Macro", 'duracelltomi-google-tag-manager' ),
|
393 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
394 |
+
"phase" => GTM4WP_PHASE_STABLE
|
395 |
+
),
|
396 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT => array(
|
397 |
+
"label" => __( "Constant Macro", 'duracelltomi-google-tag-manager' ),
|
398 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
399 |
+
"phase" => GTM4WP_PHASE_STABLE
|
400 |
+
),
|
401 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE => array(
|
402 |
+
"label" => __( "First Party Cookie Macro", 'duracelltomi-google-tag-manager' ),
|
403 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
404 |
+
"phase" => GTM4WP_PHASE_STABLE
|
405 |
+
),
|
406 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME => array(
|
407 |
+
"label" => __( "Event Name Macro", 'duracelltomi-google-tag-manager' ),
|
408 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
409 |
+
"phase" => GTM4WP_PHASE_STABLE
|
410 |
+
),
|
411 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR => array(
|
412 |
+
"label" => __( "JavaScript Variable Macro", 'duracelltomi-google-tag-manager' ),
|
413 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
414 |
+
"phase" => GTM4WP_PHASE_STABLE
|
415 |
+
),
|
416 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR => array(
|
417 |
+
"label" => __( "DataLayer Variable Macro", 'duracelltomi-google-tag-manager' ),
|
418 |
+
"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' ),
|
419 |
+
"phase" => GTM4WP_PHASE_STABLE
|
420 |
+
),
|
421 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM => array(
|
422 |
+
"label" => __( "Random Number Macro", 'duracelltomi-google-tag-manager' ),
|
423 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
424 |
+
"phase" => GTM4WP_PHASE_STABLE
|
425 |
+
),
|
426 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER => array(
|
427 |
+
"label" => __( "Referrer Macro", 'duracelltomi-google-tag-manager' ),
|
428 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
429 |
+
"phase" => GTM4WP_PHASE_STABLE
|
430 |
+
),
|
431 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_URL => array(
|
432 |
+
"label" => __( "URL Macro", 'duracelltomi-google-tag-manager' ),
|
433 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
434 |
+
"phase" => GTM4WP_PHASE_STABLE
|
435 |
+
),
|
436 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT => array(
|
437 |
+
"label" => __( "Auto-Event Variable Macro", 'duracelltomi-google-tag-manager' ),
|
438 |
+
"description" => __( "", 'duracelltomi-google-tag-manager' ),
|
439 |
+
"phase" => GTM4WP_PHASE_STABLE
|
440 |
+
)
|
441 |
+
);
|
442 |
+
|
443 |
+
$GLOBALS["gtm4wp_integratefieldtexts"] = array(
|
444 |
+
GTM4WP_OPTION_INTEGRATE_WPCF7 => array(
|
445 |
+
"label" => __( "Contact Form 7", 'duracelltomi-google-tag-manager' ),
|
446 |
+
"description" => __( "Check this to include a dataLayer event after a successfull form submission.", 'duracelltomi-google-tag-manager' ),
|
447 |
+
"phase" => GTM4WP_PHASE_STABLE,
|
448 |
+
"plugintocheck" => "contact-form-7/wp-contact-form-7.php"
|
449 |
+
),
|
450 |
+
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => array(
|
451 |
+
"label" => __( "Track classic e-commerce", 'duracelltomi-google-tag-manager' ),
|
452 |
+
"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' ),
|
453 |
+
"phase" => GTM4WP_PHASE_STABLE,
|
454 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
455 |
+
),
|
456 |
+
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => array(
|
457 |
+
"label" => __( "Track enhanced e-commerce", 'duracelltomi-google-tag-manager' ),
|
458 |
+
"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' ),
|
459 |
+
"phase" => GTM4WP_PHASE_BETA,
|
460 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
461 |
+
),
|
462 |
+
GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP => array(
|
463 |
+
"label" => __( "Cart as 1st checkout step", 'duracelltomi-google-tag-manager' ),
|
464 |
+
"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' ),
|
465 |
+
"phase" => GTM4WP_PHASE_BETA,
|
466 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
467 |
+
),
|
468 |
+
GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => array(
|
469 |
+
"label" => __( "Customer data in data layer", 'duracelltomi-google-tag-manager' ),
|
470 |
+
"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' ),
|
471 |
+
"phase" => GTM4WP_PHASE_BETA,
|
472 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
473 |
+
),
|
474 |
+
GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => array(
|
475 |
+
"label" => __( "Exclude tax from revenue", 'duracelltomi-google-tag-manager' ),
|
476 |
+
"description" => __( "Enable this to exclude tax from the revenue variable while generating the purchase data", 'duracelltomi-google-tag-manager' ),
|
477 |
+
"phase" => GTM4WP_PHASE_BETA,
|
478 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
479 |
+
),
|
480 |
+
GTM4WP_OPTION_INTEGRATE_WCREMARKETING => array(
|
481 |
+
"label" => __( "AdWords Remarketing", 'duracelltomi-google-tag-manager' ),
|
482 |
+
"description" => __( "Enable this to add Google AdWords dynamic remarketing variables to the dataLayer", 'duracelltomi-google-tag-manager' ),
|
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 |
+
"label" => __( "Include full category path.", 'duracelltomi-google-tag-manager' ),
|
500 |
+
"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' ),
|
501 |
+
"phase" => GTM4WP_PHASE_BETA,
|
502 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
503 |
+
),
|
504 |
+
GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION => array(
|
505 |
+
"label" => __( "Products per impression", 'duracelltomi-google-tag-manager' ),
|
506 |
+
"description" => __( "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 ".
|
507 |
+
"amount of data that is needed to be sent. To prevent this, you can split product impression data into multiple Google Analytics events by ".
|
508 |
+
"entering a number here (minimum 10-15 recommended) and adding gtm4wp.productImpressionEEC into your Google Analytics ecommerce event helper ".
|
509 |
+
"tag's trigger.<br /><br />Leave this value 0 to include product impression data in your pageview hit.", 'duracelltomi-google-tag-manager' ),
|
510 |
+
"phase" => GTM4WP_PHASE_BETA,
|
511 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
512 |
+
),
|
513 |
+
GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => array(
|
514 |
+
"label" => __( "Do not flag orders as being tracked", 'duracelltomi-google-tag-manager' ),
|
515 |
+
"description" => __( "Check this to prevent the plugin to flag orders as being already tracked.<br /><br />This ensures that no order data will be tracked ".
|
516 |
+
"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)!",
|
517 |
+
'duracelltomi-google-tag-manager' ),
|
518 |
+
"phase" => GTM4WP_PHASE_BETA,
|
519 |
+
"plugintocheck" => "woocommerce/woocommerce.php"
|
520 |
+
),
|
521 |
+
|
522 |
+
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => array(
|
523 |
+
"label" => __( "Google Optimize container ID list", 'duracelltomi-google-tag-manager' ),
|
524 |
+
"description" => sprintf( __( "Enter a comma separated list of Google Optimize container IDs that you would like to use on your site.<br />".
|
525 |
+
"This plugin will add the <a href=\"%s\">page-hiding snippet</a> to your pages.<br /><br />".
|
526 |
+
"The Google Optimize container will be only loaded if you provide your Google Analytics property ID bellow as well.", 'duracelltomi-google-tag-manager' ), 'https://developers.google.com/optimize/#the_page-hiding_snippet_code' ) .
|
527 |
+
'<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>',
|
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["gtm4wp_advancedfieldtexts"] = array(
|
552 |
+
GTM4WP_OPTION_DATALAYER_NAME => array(
|
553 |
+
"label" => __( "dataLayer variable name", 'duracelltomi-google-tag-manager' ),
|
554 |
+
"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' ),
|
555 |
+
"phase" => GTM4WP_PHASE_STABLE
|
556 |
+
),
|
557 |
+
GTM4WP_OPTION_ENV_GTM_AUTH => array(
|
558 |
+
"label" => __( "Environment gtm_auth parameter", 'duracelltomi-google-tag-manager' ),
|
559 |
+
"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' ),
|
560 |
+
"phase" => GTM4WP_PHASE_STABLE
|
561 |
+
),
|
562 |
+
GTM4WP_OPTION_ENV_GTM_PREVIEW => array(
|
563 |
+
"label" => __( "Environment gtm_preview parameter", 'duracelltomi-google-tag-manager' ),
|
564 |
+
"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' ),
|
565 |
+
"phase" => GTM4WP_PHASE_STABLE
|
566 |
+
),
|
567 |
+
GTM4WP_OPTION_DONOTTRACK => array(
|
568 |
+
"label" => __( "Include browser 'Do not track' setting", 'duracelltomi-google-tag-manager' ),
|
569 |
+
"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' ),
|
570 |
+
"phase" => GTM4WP_PHASE_STABLE
|
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["id"] ) {
|
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 |
+
|
586 |
+
break;
|
587 |
+
}
|
588 |
+
|
589 |
+
case GTM4WP_ADMIN_GROUP_INCLUDES: {
|
590 |
+
_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' );
|
591 |
+
echo "<br />";
|
592 |
+
printf( __( '* Browser, OS and Device data is provided using <a href="%s">WhichBrowser</a> library.', 'duracelltomi-google-tag-manager' ), "http://whichbrowser.net/" );
|
593 |
+
if ( version_compare( PHP_VERSION, '5.4.0' ) < 0 ) {
|
594 |
+
echo "<br />";
|
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 |
+
|
598 |
+
break;
|
599 |
+
}
|
600 |
+
|
601 |
+
case GTM4WP_ADMIN_GROUP_EVENTS: {
|
602 |
+
_e( "Fire tags in Google Tag Manager on special events on your website", 'duracelltomi-google-tag-manager' );
|
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>';
|
606 |
+
|
607 |
+
break;
|
608 |
+
}
|
609 |
+
|
610 |
+
case GTM4WP_ADMIN_GROUP_SCROLLER: {
|
611 |
+
_e( "Fire tags based on how the visitor scrolls through your page.", 'duracelltomi-google-tag-manager' );
|
612 |
+
echo '<br />';
|
613 |
+
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/");
|
614 |
+
|
615 |
+
break;
|
616 |
+
}
|
617 |
+
|
618 |
+
case GTM4WP_ADMIN_GROUP_BLACKLIST: {
|
619 |
+
_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' );
|
620 |
+
echo '<br />';
|
621 |
+
_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' );
|
622 |
+
echo '<br />';
|
623 |
+
_e( "Blacklisting of macros only work if you enable blacklist or whilelist of tags on the previous tab.", 'duracelltomi-google-tag-manager' );
|
624 |
+
echo '<br />';
|
625 |
+
_e( "Uncheck a row to blacklist a macro type.", 'duracelltomi-google-tag-manager' );
|
626 |
+
|
627 |
+
break;
|
628 |
+
}
|
629 |
+
|
630 |
+
case GTM4WP_ADMIN_GROUP_INTEGRATION: {
|
631 |
+
_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' );
|
632 |
+
|
633 |
+
break;
|
634 |
+
}
|
635 |
+
|
636 |
+
case GTM4WP_ADMIN_GROUP_ADVANCED: {
|
637 |
+
_e( "You usually do not need to modify thoose settings. Please be carefull while hacking here.", 'duracelltomi-google-tag-manager' );
|
638 |
+
|
639 |
+
break;
|
640 |
+
}
|
641 |
+
|
642 |
+
case GTM4WP_ADMIN_GROUP_CREDITS: {
|
643 |
+
_e( "Some info about the author of this plugin", 'duracelltomi-google-tag-manager' );
|
644 |
+
|
645 |
+
break;
|
646 |
+
}
|
647 |
+
} // end switch
|
648 |
+
|
649 |
+
echo '</span>';
|
650 |
+
}
|
651 |
+
|
652 |
+
function gtm4wp_admin_output_field( $args ) {
|
653 |
+
global $gtm4wp_options;
|
654 |
+
|
655 |
+
switch( $args["label_for"] ) {
|
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["description"];
|
658 |
+
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>';
|
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"' : '' ) . '/> ' . __( "Footer of the page (not recommended by Google, no tweak in your template required)", 'duracelltomi-google-tag-manager' ) . '<br />';
|
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"' : '' ) . '/> ' . __( "Custom (needs tweak in your template)", 'duracelltomi-google-tag-manager' ) . '<br />';
|
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"' : '' ) . '/> ' . __( "Codeless injection (no tweak, right placement but experimental, could break your frontend)", 'duracelltomi-google-tag-manager' ) . '<br />';
|
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"' : '' ) . '/> ' . __( "Off (only add data layer to the page source)", 'duracelltomi-google-tag-manager' ) . '<br /><br />' . $args["description"];
|
668 |
+
|
669 |
+
break;
|
670 |
+
}
|
671 |
+
|
672 |
+
case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_DATALAYER_NAME . "]": {
|
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["description"];
|
674 |
+
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>';
|
675 |
+
|
676 |
+
break;
|
677 |
+
}
|
678 |
+
|
679 |
+
case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_ENV_GTM_AUTH . "]": {
|
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["description"];
|
681 |
+
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>';
|
682 |
+
|
683 |
+
break;
|
684 |
+
}
|
685 |
+
|
686 |
+
case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_ENV_GTM_PREVIEW . "]": {
|
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["description"];
|
688 |
+
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>';
|
689 |
+
|
690 |
+
break;
|
691 |
+
}
|
692 |
+
|
693 |
+
case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_BLACKLIST_ENABLE . "]": {
|
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"' : '' ) . '/> ' . __( "Disable feature: control everything on Google Tag Manager interface", 'duracelltomi-google-tag-manager' ) . '<br />';
|
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"' : '' ) . '/> ' . __( "Allow all, except the checked items below (blacklist)", 'duracelltomi-google-tag-manager' ) . '<br />';
|
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"' : '' ) . '/> ' . __( "Block all, except the checked items below (whitelist)", 'duracelltomi-google-tag-manager' ) . '<br />';
|
697 |
+
echo $args["description"];
|
698 |
+
|
699 |
+
break;
|
700 |
+
}
|
701 |
+
|
702 |
+
case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . "]": {
|
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"' : '' ) . '/> ' . __( "Celsius", 'duracelltomi-google-tag-manager' ) . '<br />';
|
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"' : '' ) . '/> ' . __( "Fahrenheit", 'duracelltomi-google-tag-manager' ) . '<br />';
|
705 |
+
echo $args["description"];
|
706 |
+
|
707 |
+
break;
|
708 |
+
}
|
709 |
+
|
710 |
+
case GTM4WP_ADMIN_GROUP_INFO: {
|
711 |
+
echo $args["description"];
|
712 |
+
|
713 |
+
break;
|
714 |
+
}
|
715 |
+
|
716 |
+
default: {
|
717 |
+
$optval = $gtm4wp_options[$args["optionfieldid"]];
|
718 |
+
|
719 |
+
// fix wrong data type saved in v0.4
|
720 |
+
if ( GTM4WP_OPTION_EVENTS_SOCIAL == $args["optionfieldid"] ) {
|
721 |
+
$optval = ( boolean )( $optval );
|
722 |
+
}
|
723 |
+
|
724 |
+
switch( gettype( $optval ) ) {
|
725 |
+
case "boolean": {
|
726 |
+
echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args["optionfieldid"] . ']" name="' . GTM4WP_OPTIONS . '[' . $args["optionfieldid"] . ']" value="1" ' . checked( 1, $optval, false ) . ' /><br />' . $args["description"];
|
727 |
+
|
728 |
+
if ( isset( $args["plugintocheck"] ) && ( $args["plugintocheck"] != "" ) ) {
|
729 |
+
if ( is_plugin_active( $args["plugintocheck"] ) ) {
|
730 |
+
echo "<br />" . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
|
731 |
+
} else {
|
732 |
+
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' );
|
733 |
+
}
|
734 |
+
}
|
735 |
+
|
736 |
+
break;
|
737 |
+
}
|
738 |
+
|
739 |
+
case "integer": {
|
740 |
+
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"];
|
741 |
+
|
742 |
+
if ( isset( $args["plugintocheck"] ) && ( $args["plugintocheck"] != "" ) ) {
|
743 |
+
if ( is_plugin_active( $args["plugintocheck"] ) ) {
|
744 |
+
echo "<br />" . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
|
745 |
+
} else {
|
746 |
+
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' );
|
747 |
+
}
|
748 |
+
}
|
749 |
+
|
750 |
+
break;
|
751 |
+
}
|
752 |
+
|
753 |
+
default : {
|
754 |
+
echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . $args["optionfieldid"] . ']" name="' . GTM4WP_OPTIONS . '[' . $args["optionfieldid"] . ']" value="' . esc_attr( $optval ) . '" size="80" /><br />' . $args["description"];
|
755 |
+
|
756 |
+
if ( isset( $args["plugintocheck"] ) && ( $args["plugintocheck"] != "" ) ) {
|
757 |
+
if ( is_plugin_active( $args["plugintocheck"] ) ) {
|
758 |
+
echo "<br />" . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
|
759 |
+
} else {
|
760 |
+
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' );
|
761 |
+
}
|
762 |
+
}
|
763 |
+
}
|
764 |
+
} // end switch gettype optval
|
765 |
+
}
|
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) == "include-" ) {
|
783 |
+
$output[$optionname] = (boolean) $newoptionvalue;
|
784 |
+
|
785 |
+
// tracked download extensions
|
786 |
+
} else if ( $optionname == GTM4WP_OPTION_EVENTS_DWLEXT ) {
|
787 |
+
$output[$optionname] = str_replace( " ", "", trim( $newoptionvalue ) );
|
788 |
+
|
789 |
+
// dataLayer events
|
790 |
+
} else if ( substr($optionname, 0, 6) == "event-" ) {
|
791 |
+
$output[$optionname] = (boolean) $newoptionvalue;
|
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] && !$optionvalue ) {
|
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 |
+
}
|
798 |
+
|
799 |
+
if ( GTM4WP_OPTION_EVENTS_VIMEO == $optionname ) {
|
800 |
+
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%vimeo.com%' AND meta_key LIKE '_oembed_%'" );
|
801 |
+
}
|
802 |
+
}
|
803 |
+
|
804 |
+
// Google Optimize settings
|
805 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ) {
|
806 |
+
$_goid_val = trim($newoptionvalue);
|
807 |
+
if ( "" == $_goid_val ) {
|
808 |
+
$_goid_list = array();
|
809 |
+
} else {
|
810 |
+
$_goid_list = explode( ",", $_goid_val );
|
811 |
+
}
|
812 |
+
$_goid_haserror = false;
|
813 |
+
|
814 |
+
foreach( $_goid_list as $one_go_id ) {
|
815 |
+
$_goid_haserror = $_goid_haserror || !preg_match( "/^GTM-[A-Z0-9]+$/", $one_go_id );
|
816 |
+
}
|
817 |
+
|
818 |
+
if ( $_goid_haserror && (count($_goid_list) > 0) ) {
|
819 |
+
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' ) );
|
820 |
+
} else {
|
821 |
+
$output[$optionname] = $newoptionvalue;
|
822 |
+
}
|
823 |
+
|
824 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEGAID ) {
|
825 |
+
$_gaid_val = trim($newoptionvalue);
|
826 |
+
if ( "" == $_gaid_val ) {
|
827 |
+
$_gaid_list = array();
|
828 |
+
} else {
|
829 |
+
$_gaid_list = explode( ",", $_gaid_val );
|
830 |
+
}
|
831 |
+
$_gaid_haserror = false;
|
832 |
+
|
833 |
+
foreach( $_gaid_list as $one_ga_id ) {
|
834 |
+
$_gaid_haserror = $_gaid_haserror || !preg_match( "/^UA-[0-9]+-[0-9]+$/", $one_ga_id );
|
835 |
+
}
|
836 |
+
|
837 |
+
if ( $_gaid_haserror && (count($_gaid_list) > 0) ) {
|
838 |
+
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' ) );
|
839 |
+
} else {
|
840 |
+
$output[$optionname] = $newoptionvalue;
|
841 |
+
}
|
842 |
+
|
843 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ) {
|
844 |
+
$output[$optionname] = (int) $newoptionvalue;
|
845 |
+
|
846 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ) {
|
847 |
+
$output[$optionname] = (int) $newoptionvalue;
|
848 |
+
|
849 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ) {
|
850 |
+
$output[$optionname] = trim( (string) $newoptionvalue );
|
851 |
+
|
852 |
+
// Accelerated Mobile Pages settings
|
853 |
+
} else if ( $optionname == GTM4WP_OPTION_INTEGRATE_AMPID ) {
|
854 |
+
$_ampid_val = trim($newoptionvalue);
|
855 |
+
if ( "" == $_ampid_val ) {
|
856 |
+
$_ampid_list = array();
|
857 |
+
} else {
|
858 |
+
$_ampid_list = explode( ",", $_ampid_val );
|
859 |
+
}
|
860 |
+
$_ampid_haserror = false;
|
861 |
+
|
862 |
+
foreach( $_ampid_list as $one_amp_id ) {
|
863 |
+
$_ampid_haserror = $_ampid_haserror || !preg_match( "/^GTM-[A-Z0-9]+$/", $one_amp_id );
|
864 |
+
}
|
865 |
+
|
866 |
+
if ( $_ampid_haserror && (count($_ampid_list) > 0) ) {
|
867 |
+
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' ) );
|
868 |
+
} else {
|
869 |
+
$output[$optionname] = $newoptionvalue;
|
870 |
+
}
|
871 |
+
|
872 |
+
|
873 |
+
// integrations
|
874 |
+
} else if ( substr($optionname, 0, 10) == "integrate-" ) {
|
875 |
+
$output[$optionname] = (boolean) $newoptionvalue;
|
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 = explode( ",", $newoptionvalue );
|
883 |
+
$_gtmid_haserror = false;
|
884 |
+
|
885 |
+
foreach( $_gtmid_list as $one_gtm_id ) {
|
886 |
+
$_gtmid_haserror = $_gtmid_haserror || !preg_match( "/^GTM-[A-Z0-9]+$/", $one_gtm_id );
|
887 |
+
}
|
888 |
+
|
889 |
+
if ( $_gtmid_haserror ) {
|
890 |
+
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' ) );
|
891 |
+
} else {
|
892 |
+
$output[$optionname] = $newoptionvalue;
|
893 |
+
}
|
894 |
+
} else if ( ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^[a-zA-Z][a-zA-Z0-9_-]*$/", $newoptionvalue ) ) ) {
|
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 |
+
} else if ( ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^[a-zA-Z0-9-_]+$/", $newoptionvalue ) ) ) {
|
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 |
+
} else if ( ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^env-[0-9]+$/", $newoptionvalue ) ) ) {
|
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 |
+
// GTM container code placement
|
908 |
+
} else if ( $optionname == GTM4WP_OPTION_GTM_PLACEMENT ) {
|
909 |
+
$output[$optionname] = (int) $newoptionvalue;
|
910 |
+
if ( ( $output[$optionname] < 0) || ( $output[$optionname] > 3 ) ) {
|
911 |
+
$output[$optionname] = 0;
|
912 |
+
}
|
913 |
+
|
914 |
+
// scroll tracking content ID
|
915 |
+
} else if ( $optionname == GTM4WP_OPTION_SCROLLER_CONTENTID ) {
|
916 |
+
$output[$optionname] = trim( str_replace( "#", "", $newoptionvalue ) );
|
917 |
+
|
918 |
+
// anything else
|
919 |
+
} else {
|
920 |
+
switch( gettype($optionvalue)) {
|
921 |
+
case "boolean": {
|
922 |
+
$output[$optionname] = (boolean) $newoptionvalue;
|
923 |
+
|
924 |
+
break;
|
925 |
+
}
|
926 |
+
|
927 |
+
case "integer": {
|
928 |
+
$output[$optionname] = (int) $newoptionvalue;
|
929 |
+
|
930 |
+
break;
|
931 |
+
}
|
932 |
+
|
933 |
+
default: {
|
934 |
+
$output[$optionname] = $newoptionvalue;
|
935 |
+
}
|
936 |
+
} // end switch
|
937 |
+
}
|
938 |
+
}
|
939 |
+
|
940 |
+
return $output;
|
941 |
+
}
|
942 |
+
|
943 |
+
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, "gtm4wp_sanitize_options" );
|
948 |
+
|
949 |
+
add_settings_section(
|
950 |
+
GTM4WP_ADMIN_GROUP_GENERAL,
|
951 |
+
__( 'General', 'duracelltomi-google-tag-manager' ),
|
952 |
+
'gtm4wp_admin_output_section',
|
953 |
+
GTM4WP_ADMINSLUG
|
954 |
+
);
|
955 |
+
|
956 |
+
add_settings_field(
|
957 |
+
GTM4WP_ADMIN_GROUP_GTMID,
|
958 |
+
__( 'Google Tag Manager ID', 'duracelltomi-google-tag-manager' ),
|
959 |
+
'gtm4wp_admin_output_field',
|
960 |
+
GTM4WP_ADMINSLUG,
|
961 |
+
GTM4WP_ADMIN_GROUP_GENERAL,
|
962 |
+
array(
|
963 |
+
"label_for" => GTM4WP_ADMIN_GROUP_GTMID,
|
964 |
+
"description" => __( "Enter your Google Tag Manager ID here. Use comma without space (,) to enter multiple IDs.", 'duracelltomi-google-tag-manager' )
|
965 |
+
)
|
966 |
+
);
|
967 |
+
|
968 |
+
add_settings_field(
|
969 |
+
GTM4WP_ADMIN_GROUP_PLACEMENT,
|
970 |
+
__( 'Container code placement', 'duracelltomi-google-tag-manager' ),
|
971 |
+
'gtm4wp_admin_output_field',
|
972 |
+
GTM4WP_ADMINSLUG,
|
973 |
+
GTM4WP_ADMIN_GROUP_GENERAL,
|
974 |
+
array(
|
975 |
+
"label_for" => GTM4WP_ADMIN_GROUP_PLACEMENT,
|
976 |
+
// "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' )
|
977 |
+
"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' )
|
978 |
+
)
|
979 |
+
);
|
980 |
+
|
981 |
+
add_settings_section(
|
982 |
+
GTM4WP_ADMIN_GROUP_INCLUDES,
|
983 |
+
__( 'Basic data', 'duracelltomi-google-tag-manager' ),
|
984 |
+
'gtm4wp_admin_output_section',
|
985 |
+
GTM4WP_ADMINSLUG
|
986 |
+
);
|
987 |
+
|
988 |
+
foreach($gtm4wp_includefieldtexts as $fieldid => $fielddata) {
|
989 |
+
add_settings_field(
|
990 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
991 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
992 |
+
'gtm4wp_admin_output_field',
|
993 |
+
GTM4WP_ADMINSLUG,
|
994 |
+
GTM4WP_ADMIN_GROUP_INCLUDES,
|
995 |
+
array(
|
996 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
997 |
+
"description" => $fielddata["description"],
|
998 |
+
"optionfieldid" => $fieldid
|
999 |
+
)
|
1000 |
+
);
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
add_settings_section(
|
1004 |
+
GTM4WP_ADMIN_GROUP_EVENTS,
|
1005 |
+
__( 'Events', 'duracelltomi-google-tag-manager' ),
|
1006 |
+
'gtm4wp_admin_output_section',
|
1007 |
+
GTM4WP_ADMINSLUG
|
1008 |
+
);
|
1009 |
+
|
1010 |
+
foreach($gtm4wp_eventfieldtexts as $fieldid => $fielddata) {
|
1011 |
+
add_settings_field(
|
1012 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
1013 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
1014 |
+
'gtm4wp_admin_output_field',
|
1015 |
+
GTM4WP_ADMINSLUG,
|
1016 |
+
GTM4WP_ADMIN_GROUP_EVENTS,
|
1017 |
+
array(
|
1018 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
1019 |
+
"description" => $fielddata["description"],
|
1020 |
+
"optionfieldid" => $fieldid
|
1021 |
+
)
|
1022 |
+
);
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
add_settings_section(
|
1026 |
+
GTM4WP_ADMIN_GROUP_SCROLLER,
|
1027 |
+
__( 'Scroll tracking', 'duracelltomi-google-tag-manager' ),
|
1028 |
+
'gtm4wp_admin_output_section',
|
1029 |
+
GTM4WP_ADMINSLUG
|
1030 |
+
);
|
1031 |
+
|
1032 |
+
foreach($gtm4wp_scrollerfieldtexts as $fieldid => $fielddata) {
|
1033 |
+
add_settings_field(
|
1034 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
1035 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
1036 |
+
'gtm4wp_admin_output_field',
|
1037 |
+
GTM4WP_ADMINSLUG,
|
1038 |
+
GTM4WP_ADMIN_GROUP_SCROLLER,
|
1039 |
+
array(
|
1040 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
1041 |
+
"description" => $fielddata["description"],
|
1042 |
+
"optionfieldid" => $fieldid
|
1043 |
+
)
|
1044 |
+
);
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
add_settings_section(
|
1048 |
+
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1049 |
+
__( 'Blacklist tags', 'duracelltomi-google-tag-manager' ),
|
1050 |
+
'gtm4wp_admin_output_section',
|
1051 |
+
GTM4WP_ADMINSLUG
|
1052 |
+
);
|
1053 |
+
|
1054 |
+
foreach($gtm4wp_blacklistfieldtexts as $fieldid => $fielddata) {
|
1055 |
+
add_settings_field(
|
1056 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
1057 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
1058 |
+
'gtm4wp_admin_output_field',
|
1059 |
+
GTM4WP_ADMINSLUG,
|
1060 |
+
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1061 |
+
array(
|
1062 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
1063 |
+
"description" => $fielddata["description"],
|
1064 |
+
"optionfieldid" => $fieldid
|
1065 |
+
)
|
1066 |
+
);
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
foreach($gtm4wp_blacklistmfieldtexts as $fieldid => $fielddata) {
|
1070 |
+
add_settings_field(
|
1071 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
1072 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
1073 |
+
'gtm4wp_admin_output_field',
|
1074 |
+
GTM4WP_ADMINSLUG,
|
1075 |
+
GTM4WP_ADMIN_GROUP_BLACKLIST,
|
1076 |
+
array(
|
1077 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
1078 |
+
"description" => $fielddata["description"],
|
1079 |
+
"optionfieldid" => $fieldid
|
1080 |
+
)
|
1081 |
+
);
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
add_settings_section(
|
1085 |
+
GTM4WP_ADMIN_GROUP_INTEGRATION,
|
1086 |
+
__( 'Integration', 'duracelltomi-google-tag-manager' ),
|
1087 |
+
'gtm4wp_admin_output_section',
|
1088 |
+
GTM4WP_ADMINSLUG
|
1089 |
+
);
|
1090 |
+
|
1091 |
+
foreach($gtm4wp_integratefieldtexts as $fieldid => $fielddata) {
|
1092 |
+
add_settings_field(
|
1093 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
1094 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
1095 |
+
'gtm4wp_admin_output_field',
|
1096 |
+
GTM4WP_ADMINSLUG,
|
1097 |
+
GTM4WP_ADMIN_GROUP_INTEGRATION,
|
1098 |
+
array(
|
1099 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
1100 |
+
"description" => $fielddata["description"],
|
1101 |
+
"optionfieldid" => $fieldid,
|
1102 |
+
"plugintocheck" => isset( $fielddata["plugintocheck"] ) ? $fielddata["plugintocheck"] : ""
|
1103 |
+
)
|
1104 |
+
);
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
add_settings_section(
|
1108 |
+
GTM4WP_ADMIN_GROUP_ADVANCED,
|
1109 |
+
__( 'Advanced', 'duracelltomi-google-tag-manager' ),
|
1110 |
+
'gtm4wp_admin_output_section',
|
1111 |
+
GTM4WP_ADMINSLUG
|
1112 |
+
);
|
1113 |
+
|
1114 |
+
foreach($gtm4wp_advancedfieldtexts as $fieldid => $fielddata) {
|
1115 |
+
add_settings_field(
|
1116 |
+
"gtm4wp-admin-" . $fieldid . "-id",
|
1117 |
+
$fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',
|
1118 |
+
'gtm4wp_admin_output_field',
|
1119 |
+
GTM4WP_ADMINSLUG,
|
1120 |
+
GTM4WP_ADMIN_GROUP_ADVANCED,
|
1121 |
+
array(
|
1122 |
+
"label_for" => "gtm4wp-options[" . $fieldid . "]",
|
1123 |
+
"description" => $fielddata["description"],
|
1124 |
+
"optionfieldid" => $fieldid,
|
1125 |
+
"plugintocheck" => isset( $fielddata["plugintocheck"] ) ? $fielddata["plugintocheck"] : ""
|
1126 |
+
)
|
1127 |
+
);
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
add_settings_section(
|
1131 |
+
GTM4WP_ADMIN_GROUP_CREDITS,
|
1132 |
+
__( 'Credits', 'duracelltomi-google-tag-manager' ),
|
1133 |
+
'gtm4wp_admin_output_section',
|
1134 |
+
GTM4WP_ADMINSLUG
|
1135 |
+
);
|
1136 |
+
|
1137 |
+
add_settings_field(
|
1138 |
+
GTM4WP_ADMIN_GROUP_INFO,
|
1139 |
+
__( 'Author', 'duracelltomi-google-tag-manager' ),
|
1140 |
+
'gtm4wp_admin_output_field',
|
1141 |
+
GTM4WP_ADMINSLUG,
|
1142 |
+
GTM4WP_ADMIN_GROUP_CREDITS,
|
1143 |
+
array(
|
1144 |
+
"label_for" => GTM4WP_ADMIN_GROUP_INFO,
|
1145 |
+
"description" => '<strong>Thomas Geiger</strong><br />
|
1146 |
+
Website: <a href="https://gtm4wp.com/" target="_blank">gtm4wp.com</a><br />
|
1147 |
+
<a href="https://www.linkedin.com/in/duracelltomi" target="_blank">Me on LinkedIn</a><br />
|
1148 |
+
<a href="http://www.linkedin.com/company/jabjab-online-marketing-ltd-" target="_blank">JabJab Online Marketing on LinkedIn</a>'
|
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( dirname( __FILE__ ) . "/../integration/youtube.php" );
|
1155 |
+
require_once( dirname( __FILE__ ) . "/../integration/vimeo.php" );
|
1156 |
+
require_once( dirname( __FILE__ ) . "/../integration/soundcloud.php" );
|
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() {
|
1176 |
+
add_options_page(
|
1177 |
+
__( 'Google Tag Manager for WordPress settings', 'duracelltomi-google-tag-manager' ),
|
1178 |
+
__( 'Google Tag Manager', 'duracelltomi-google-tag-manager' ),
|
1179 |
+
'manage_options',
|
1180 |
+
GTM4WP_ADMINSLUG,
|
1181 |
+
'gtm4wp_show_admin_page'
|
1182 |
+
);
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
function gtm4wp_add_admin_js($hook) {
|
1186 |
+
global $gtp4wp_plugin_url;
|
1187 |
+
|
1188 |
+
if ( $hook == "settings_page_" . GTM4WP_ADMINSLUG ) {
|
1189 |
+
wp_register_script( "admin-subtabs", $gtp4wp_plugin_url . "js/admin-subtabs.js", array(), GTM4WP_VERSION );
|
1190 |
+
|
1191 |
+
$subtabtexts = array(
|
1192 |
+
"posttabtitle" => __( "Posts" , 'duracelltomi-google-tag-manager' ),
|
1193 |
+
"searchtabtitle" => __( "Search" , 'duracelltomi-google-tag-manager' ),
|
1194 |
+
"visitortabtitle" => __( "Visitors" , 'duracelltomi-google-tag-manager' ),
|
1195 |
+
"adwordstabtitle" => __( "AdWords" , 'duracelltomi-google-tag-manager' ),
|
1196 |
+
"browsertabtitle" => __( "Browser/OS/Device" , 'duracelltomi-google-tag-manager' ),
|
1197 |
+
"blocktagstabtitle" => __( "Blacklist tags" , 'duracelltomi-google-tag-manager' ),
|
1198 |
+
"blockmacrostabtitle" => __( "Blacklist macros" , 'duracelltomi-google-tag-manager' ),
|
1199 |
+
"wpcf7tabtitle" => __( "Contact Form 7" , 'duracelltomi-google-tag-manager' ),
|
1200 |
+
"wctabtitle" => __( "WooCommerce" , 'duracelltomi-google-tag-manager' ),
|
1201 |
+
"gotabtitle" => __( "Google Optimize" , 'duracelltomi-google-tag-manager' ),
|
1202 |
+
"amptabtitle" => __( "Accelerated Mobile Pages" , 'duracelltomi-google-tag-manager' ),
|
1203 |
+
"weathertabtitle" => __( "Weather data" , 'duracelltomi-google-tag-manager' ),
|
1204 |
+
"generaleventstabtitle" => __( "General events" , 'duracelltomi-google-tag-manager' ),
|
1205 |
+
"mediaeventstabtitle" => __( "Media events" , 'duracelltomi-google-tag-manager' ),
|
1206 |
+
"depecratedeventstabtitle" => __( "Deprecated" , 'duracelltomi-google-tag-manager' ),
|
1207 |
+
"sitetabtitle" => __( "Site" , 'duracelltomi-google-tag-manager' ),
|
1208 |
+
"misctabtitle" => __( "Misc" , 'duracelltomi-google-tag-manager' )
|
1209 |
+
);
|
1210 |
+
wp_localize_script( "admin-subtabs", 'gtm4wp', $subtabtexts );
|
1211 |
+
|
1212 |
+
wp_enqueue_script( "admin-subtabs", array(), GTM4WP_VERSION );
|
1213 |
+
wp_enqueue_script( "admin-tabcreator", $gtp4wp_plugin_url . "js/admin-tabcreator.js", array( "jquery-core" ), GTM4WP_VERSION );
|
1214 |
+
|
1215 |
+
wp_enqueue_style( "gtm4wp-validate", $gtp4wp_plugin_url . "css/admin-gtm4wp.css", array(), GTM4WP_VERSION );
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
function gtm4wp_admin_head() {
|
1220 |
+
echo '
|
1221 |
+
<style type="text/css">
|
1222 |
+
.gtmid_validation_error,
|
1223 |
+
.goid_validation_error,
|
1224 |
+
.goid_ga_validation_error,
|
1225 |
+
.ampid_validation_error,
|
1226 |
+
.datalayername_validation_error,
|
1227 |
+
.gtmauth_validation_error,
|
1228 |
+
.gtmpreview_validation_error {
|
1229 |
+
display: none;
|
1230 |
+
color: #c00;
|
1231 |
+
font-weight: bold;
|
1232 |
+
}
|
1233 |
+
</style>
|
1234 |
+
<script type="text/javascript">
|
1235 |
+
jQuery(function() {
|
1236 |
+
jQuery( "#gtm4wp-options\\\\[gtm-code\\\\]" )
|
1237 |
+
.bind( "blur", function() {
|
1238 |
+
var gtmid_regex = /^GTM-[A-Z0-9]+$/;
|
1239 |
+
var gtmid_list = jQuery( this ).val().trim().split( "," );
|
1240 |
+
|
1241 |
+
var gtmid_haserror = false;
|
1242 |
+
for( var i=0; i<gtmid_list.length; i++ ) {
|
1243 |
+
gtmid_haserror = gtmid_haserror || !gtmid_regex.test( gtmid_list[ i ] );
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
if ( gtmid_haserror ) {
|
1247 |
+
jQuery( ".gtmid_validation_error" )
|
1248 |
+
.show();
|
1249 |
+
} else {
|
1250 |
+
jQuery( ".gtmid_validation_error" )
|
1251 |
+
.hide();
|
1252 |
+
}
|
1253 |
+
});
|
1254 |
+
|
1255 |
+
jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-idlist\\\\]" )
|
1256 |
+
.bind( "blur", function() {
|
1257 |
+
var goid_regex = /^GTM-[A-Z0-9]+$/;
|
1258 |
+
var goid_val = jQuery( this ).val().trim();
|
1259 |
+
if ( "" == goid_val ) {
|
1260 |
+
goid_list = [];
|
1261 |
+
} else {
|
1262 |
+
var goid_list = goid_val.split( "," );
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
var goid_haserror = false;
|
1266 |
+
for( var i=0; i<goid_list.length; i++ ) {
|
1267 |
+
goid_haserror = goid_haserror || !goid_regex.test( goid_list[ i ] );
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
if ( goid_haserror && (goid_list.length > 0) ) {
|
1271 |
+
jQuery( ".goid_validation_error" )
|
1272 |
+
.show();
|
1273 |
+
} else {
|
1274 |
+
jQuery( ".goid_validation_error" )
|
1275 |
+
.hide();
|
1276 |
+
}
|
1277 |
+
});
|
1278 |
+
|
1279 |
+
jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-gaid\\\\]" )
|
1280 |
+
.bind( "blur", function() {
|
1281 |
+
var gogaid_regex = /^UA-[0-9]+-[0-9]+$/;
|
1282 |
+
var gogaid_val = jQuery( this ).val().trim();
|
1283 |
+
if ( "" == gogaid_val ) {
|
1284 |
+
gogaid_list = [];
|
1285 |
+
} else {
|
1286 |
+
var gogaid_list = gogaid_val.split( "," );
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
var gogaid_haserror = false;
|
1290 |
+
for( var i=0; i<gogaid_list.length; i++ ) {
|
1291 |
+
gogaid_haserror = gogaid_haserror || !gogaid_regex.test( gogaid_list[ i ] );
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
if ( gogaid_haserror && (gogaid_list.length > 0) ) {
|
1295 |
+
jQuery( ".goid_ga_validation_error" )
|
1296 |
+
.show();
|
1297 |
+
} else {
|
1298 |
+
jQuery( ".goid_ga_validation_error" )
|
1299 |
+
.hide();
|
1300 |
+
}
|
1301 |
+
});
|
1302 |
+
|
1303 |
+
jQuery( "#gtm4wp-options\\\\[integrate-amp-gtm\\\\]" )
|
1304 |
+
.bind( "blur", function() {
|
1305 |
+
var ampid_regex = /^GTM-[A-Z0-9]+$/;
|
1306 |
+
var ampid_val = jQuery( this ).val().trim();
|
1307 |
+
if ( "" == ampid_val ) {
|
1308 |
+
ampid_list = [];
|
1309 |
+
} else {
|
1310 |
+
var ampid_list = ampid_val.split( "," );
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
var ampid_haserror = false;
|
1314 |
+
for( var i=0; i<ampid_list.length; i++ ) {
|
1315 |
+
ampid_haserror = ampid_haserror || !ampid_regex.test( gogaid_list[ i ] );
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
if ( ampid_haserror && (ampid_list.length > 0) ) {
|
1319 |
+
jQuery( ".ampid_validation_error" )
|
1320 |
+
.show();
|
1321 |
+
} else {
|
1322 |
+
jQuery( ".ampid_validation_error" )
|
1323 |
+
.hide();
|
1324 |
+
}
|
1325 |
+
});
|
1326 |
+
|
1327 |
+
jQuery( "#gtm4wp-options\\\\[gtm-datalayer-variable-name\\\\]" )
|
1328 |
+
.bind( "blur", function() {
|
1329 |
+
var currentval = jQuery( this ).val();
|
1330 |
+
|
1331 |
+
jQuery( ".datalayername_validation_error" )
|
1332 |
+
.hide();
|
1333 |
+
|
1334 |
+
if ( currentval != "" ) {
|
1335 |
+
// I know this is not the exact definition for a variable name but I think other kind of variable names should not be used.
|
1336 |
+
var gtmvarname_regex = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
1337 |
+
if ( ! gtmvarname_regex.test( currentval ) ) {
|
1338 |
+
jQuery( ".datalayername_validation_error" )
|
1339 |
+
.show();
|
1340 |
+
}
|
1341 |
+
}
|
1342 |
+
});
|
1343 |
+
|
1344 |
+
jQuery( "#gtm4wp-options\\\\[gtm-env-gtm-auth\\\\]" )
|
1345 |
+
.bind( "blur", function() {
|
1346 |
+
var currentval = jQuery( this ).val();
|
1347 |
+
|
1348 |
+
jQuery( ".gtmauth_validation_error" )
|
1349 |
+
.hide();
|
1350 |
+
|
1351 |
+
if ( currentval != "" ) {
|
1352 |
+
var gtmauth_regex = /^[a-zA-Z0-9-_]+$/;
|
1353 |
+
if ( ! gtmauth_regex.test( currentval ) ) {
|
1354 |
+
jQuery( ".gtmauth_validation_error" )
|
1355 |
+
.show();
|
1356 |
+
}
|
1357 |
+
}
|
1358 |
+
});
|
1359 |
+
|
1360 |
+
jQuery( "#gtm4wp-options\\\\[gtm-env-gtm-preview\\\\]" )
|
1361 |
+
.bind( "blur", function() {
|
1362 |
+
var currentval = jQuery( this ).val();
|
1363 |
+
|
1364 |
+
jQuery( ".gtmpreview_validation_error" )
|
1365 |
+
.hide();
|
1366 |
+
|
1367 |
+
if ( currentval != "" ) {
|
1368 |
+
var gtmpreview_regex = /^env-[0-9]+$/;
|
1369 |
+
if ( ! gtmpreview_regex.test( currentval ) ) {
|
1370 |
+
jQuery( ".gtmpreview_validation_error" )
|
1371 |
+
.show();
|
1372 |
+
}
|
1373 |
+
}
|
1374 |
+
});
|
1375 |
+
|
1376 |
+
jQuery( document )
|
1377 |
+
.on( "click", ".gtm4wp-notice .notice-dismiss", function( e ) {
|
1378 |
+
jQuery.post(ajaxurl, {
|
1379 |
+
action: "gtm4wp_dismiss_notice",
|
1380 |
+
noticeid: jQuery( this ).closest(".gtm4wp-notice")
|
1381 |
+
.attr( "data-href" )
|
1382 |
+
.substring( 1 )
|
1383 |
+
});
|
1384 |
+
});
|
1385 |
+
});
|
1386 |
+
</script>';
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
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 ][ "plugintocheck" ] );
|
1394 |
+
if ( $woo_plugin_active ) {
|
1395 |
+
$woo = WC();
|
1396 |
+
} else {
|
1397 |
+
$woo = NULL;
|
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 |
+
$gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
|
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] ) == "" ) && ( false === $gtm4wp_user_notices_dismisses["enter-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' ), "options-general.php?page=" . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
if ((
|
1416 |
+
("" != $gtm4wp_options[GTM4WP_OPTION_ENV_GTM_AUTH]) && ("" == $gtm4wp_options[GTM4WP_OPTION_ENV_GTM_PREVIEW])
|
1417 |
+
) || (
|
1418 |
+
("" == $gtm4wp_options[GTM4WP_OPTION_ENV_GTM_AUTH]) && ("" != $gtm4wp_options[GTM4WP_OPTION_ENV_GTM_PREVIEW])
|
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' ), "options-general.php?page=" . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
|
1421 |
+
}
|
1422 |
+
|
1423 |
+
if ( ( false === $gtm4wp_user_notices_dismisses["wc-ga-plugin-warning"] ) || ( false === $gtm4wp_user_notices_dismisses["wc-gayoast-plugin-warning"] ) ) {
|
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["wc-ga-plugin-warning"] ) && $is_wc_active && $woo && ( version_compare( $woo->version, "2.1" ) < 0 ) ) {
|
1429 |
+
$woo_ga_options = get_option( "woocommerce_google_analytics_settings" );
|
1430 |
+
if ( $woo_ga_options ) {
|
1431 |
+
if ( "" != $woo_ga_options["ga_id"] ) {
|
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["wc-ga-plugin-warning"] ) && $is_wc_active && is_plugin_active( "woocommerce-google-analytics-integration/woocommerce-google-analytics-integration.php" ) ) {
|
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["wc-gayoast-plugin-warning"] ) && $is_wc_active && is_plugin_active( "google-analytics-for-wordpress/googleanalytics.php" ) ) {
|
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["php56-warning"] ) && ( version_compare( PHP_VERSION, '5.6.0' ) < 0 ) ) {
|
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["woo2x-warning"] ) && ( $woo ) && ( version_compare( $woo->version, "3.0", "<" ) ) ) {
|
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["deprecated-warning"] ) && (
|
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 |
+
"Social actions",
|
1462 |
+
"Outbound link click events",
|
1463 |
+
"Download click events",
|
1464 |
+
"Email click events"
|
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 |
+
}
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
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 |
+
$gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
|
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["noticeid"] ) );
|
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 ) );
|
1488 |
+
}
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
function gtm4wp_add_plugin_action_links( $links, $file ) {
|
1492 |
+
global $gtp4wp_plugin_basename;
|
1493 |
+
|
1494 |
+
if ( $file != $gtp4wp_plugin_basename )
|
1495 |
+
return $links;
|
1496 |
+
|
1497 |
+
$settings_link = '<a href="' . menu_page_url( GTM4WP_ADMINSLUG, false ) . '">' . esc_html( __( 'Settings' ) ) . '</a>';
|
1498 |
+
|
1499 |
+
array_unshift( $links, $settings_link );
|
1500 |
+
|
1501 |
+
return $links;
|
1502 |
+
}
|
1503 |
+
|
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 |
+
|
1511 |
+
add_action( 'admin_init', 'gtm4wp_admin_init' );
|
1512 |
+
add_action( 'admin_menu', 'gtm4wp_add_admin_page' );
|
1513 |
+
add_action( 'admin_enqueue_scripts', 'gtm4wp_add_admin_js' );
|
1514 |
+
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 );
|
common/readoptions.php
CHANGED
@@ -1,244 +1,269 @@
|
|
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 |
-
|
9 |
-
define( '
|
10 |
-
|
11 |
-
define( '
|
12 |
-
define( '
|
13 |
-
define( '
|
14 |
-
define( '
|
15 |
-
define( '
|
16 |
-
define( '
|
17 |
-
define( '
|
18 |
-
define( '
|
19 |
-
define( '
|
20 |
-
define( '
|
21 |
-
define( '
|
22 |
-
define( '
|
23 |
-
define( '
|
24 |
-
define( '
|
25 |
-
define( '
|
26 |
-
define( '
|
27 |
-
define( '
|
28 |
-
define( '
|
29 |
-
define( '
|
30 |
-
define( '
|
31 |
-
define( '
|
32 |
-
define( '
|
33 |
-
define( '
|
34 |
-
define( '
|
35 |
-
define( '
|
36 |
-
define( '
|
37 |
-
|
38 |
-
define( '
|
39 |
-
define( '
|
40 |
-
|
41 |
-
define( '
|
42 |
-
define( '
|
43 |
-
define( '
|
44 |
-
define( '
|
45 |
-
define( '
|
46 |
-
|
47 |
-
|
48 |
-
define( '
|
49 |
-
define( '
|
50 |
-
|
51 |
-
define( '
|
52 |
-
define( '
|
53 |
-
define( '
|
54 |
-
|
55 |
-
define( '
|
56 |
-
define( '
|
57 |
-
define( '
|
58 |
-
define( '
|
59 |
-
define( '
|
60 |
-
define( '
|
61 |
-
|
62 |
-
define( '
|
63 |
-
define( '
|
64 |
-
define( '
|
65 |
-
define( '
|
66 |
-
define( '
|
67 |
-
define( '
|
68 |
-
define( '
|
69 |
-
define( '
|
70 |
-
define( '
|
71 |
-
define( '
|
72 |
-
define( '
|
73 |
-
define( '
|
74 |
-
define( '
|
75 |
-
|
76 |
-
define( '
|
77 |
-
define( '
|
78 |
-
define( '
|
79 |
-
define( '
|
80 |
-
define( '
|
81 |
-
define( '
|
82 |
-
|
83 |
-
define( '
|
84 |
-
define( '
|
85 |
-
define( '
|
86 |
-
define( '
|
87 |
-
|
88 |
-
define( '
|
89 |
-
|
90 |
-
define( '
|
91 |
-
define( '
|
92 |
-
define( '
|
93 |
-
define( '
|
94 |
-
|
95 |
-
define( '
|
96 |
-
|
97 |
-
define( '
|
98 |
-
define( '
|
99 |
-
|
100 |
-
define( '
|
101 |
-
define( '
|
102 |
-
|
103 |
-
define( '
|
104 |
-
|
105 |
-
|
106 |
-
define( '
|
107 |
-
define( '
|
108 |
-
define( '
|
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 |
-
|
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 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_SEARCHDATA', 'include-searchdata' );
|
30 |
+
define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
|
31 |
+
define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
|
32 |
+
define( 'GTM4WP_OPTION_INCLUDE_DEVICEDATA', 'include-devicedata' );
|
33 |
+
define( 'GTM4WP_OPTION_INCLUDE_MISCGEO', 'include-miscgeo' );
|
34 |
+
define( 'GTM4WP_OPTION_INCLUDE_MISCGEOAPI', 'geo-apikey' );
|
35 |
+
define( 'GTM4WP_OPTION_INCLUDE_WEATHER', 'include-weather' );
|
36 |
+
define( 'GTM4WP_OPTION_INCLUDE_WEATHERUNITS', 'weather-weatherunits' );
|
37 |
+
define( 'GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI', 'weather-openweathermap-apikey' );
|
38 |
+
define( 'GTM4WP_OPTION_INCLUDE_SITEID', 'include-siteid' );
|
39 |
+
define( 'GTM4WP_OPTION_INCLUDE_SITENAME', 'include-sitename' );
|
40 |
+
|
41 |
+
define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
|
42 |
+
define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
|
43 |
+
define( 'GTM4WP_OPTION_EVENTS_DWLEXT', 'event-download-extensions' );
|
44 |
+
define( 'GTM4WP_OPTION_EVENTS_EMAILCLICKS', 'event-email-clicks' );
|
45 |
+
define( 'GTM4WP_OPTION_EVENTS_SOCIAL', 'event-social' );
|
46 |
+
|
47 |
+
define( 'GTM4WP_OPTION_EVENTS_FORMMOVE', 'event-form-move' );
|
48 |
+
define( 'GTM4WP_OPTION_EVENTS_NEWUSERREG', 'event-new-user-registration' );
|
49 |
+
define( 'GTM4WP_OPTION_EVENTS_USERLOGIN', 'event-user-logged-in' );
|
50 |
+
|
51 |
+
define( 'GTM4WP_OPTION_EVENTS_YOUTUBE', 'event-youtube' );
|
52 |
+
define( 'GTM4WP_OPTION_EVENTS_VIMEO', 'event-vimeo' );
|
53 |
+
define( 'GTM4WP_OPTION_EVENTS_SOUNDCLOUD', 'event-soundcloud' );
|
54 |
+
|
55 |
+
define( 'GTM4WP_OPTION_SCROLLER_ENABLED', 'scroller-enabled' );
|
56 |
+
define( 'GTM4WP_OPTION_SCROLLER_DEBUGMODE', 'scroller-debug-mode' );
|
57 |
+
define( 'GTM4WP_OPTION_SCROLLER_CALLBACKTIME', 'scroller-callback-time' );
|
58 |
+
define( 'GTM4WP_OPTION_SCROLLER_DISTANCE', 'scroller-distance' );
|
59 |
+
define( 'GTM4WP_OPTION_SCROLLER_CONTENTID', 'scroller-contentid' );
|
60 |
+
define( 'GTM4WP_OPTION_SCROLLER_READERTIME', 'scroller-readertime' );
|
61 |
+
|
62 |
+
define( 'GTM4WP_OPTION_BLACKLIST_ENABLE', 'blacklist-enable' );
|
63 |
+
define( 'GTM4WP_OPTION_BLACKLIST_ADADVISOR', 'blacklist-adadvisor' );
|
64 |
+
define( 'GTM4WP_OPTION_BLACKLIST_ADROLL', 'blacklist-adroll' );
|
65 |
+
define( 'GTM4WP_OPTION_BLACKLIST_AWCONV', 'blacklist-adwords-conversion' );
|
66 |
+
define( 'GTM4WP_OPTION_BLACKLIST_AWREMARKET', 'blacklist-adwords-remarketing' );
|
67 |
+
define( 'GTM4WP_OPTION_BLACKLIST_BIZO', 'blacklist-bizo' );
|
68 |
+
define( 'GTM4WP_OPTION_BLACKLIST_CLICKTALE', 'blacklist-clicktale' );
|
69 |
+
define( 'GTM4WP_OPTION_BLACKLIST_COMSCORE', 'blacklist-comscore' );
|
70 |
+
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMHTML', 'blacklist-custom-html' );
|
71 |
+
define( 'GTM4WP_OPTION_BLACKLIST_CUSTOMIMG', 'blacklist-custom-img-tag' );
|
72 |
+
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT', 'blacklist-doubleclick-counter' );
|
73 |
+
define( 'GTM4WP_OPTION_BLACKLIST_DBLCLKSALES', 'blacklist-doubleclick-sales' );
|
74 |
+
define( 'GTM4WP_OPTION_BLACKLIST_GACLASSIC', 'blacklist-google-analytics' );
|
75 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MARIN', 'blacklist-marin' );
|
76 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME', 'blacklist-mediaplex-iframe' );
|
77 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MPLEXROI', 'blacklist-mediaplex-roi' );
|
78 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MEDIA6DEG', 'blacklist-media6degrees' );
|
79 |
+
define( 'GTM4WP_OPTION_BLACKLIST_TURNCONV', 'blacklist-turn-conversion' );
|
80 |
+
define( 'GTM4WP_OPTION_BLACKLIST_TURNDATA', 'blacklist-turn-data' );
|
81 |
+
define( 'GTM4WP_OPTION_BLACKLIST_UA', 'blacklist-universal-analytics' );
|
82 |
+
|
83 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT', 'blacklist-macro-dom-element' );
|
84 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS', 'blacklist-macro-custom-js' );
|
85 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT', 'blacklist-macro-constant-string' );
|
86 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE', 'blacklist-macro-1st-party-cookie' );
|
87 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME', 'blacklist-macro-event-name' );
|
88 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR', 'blacklist-macro-javascript-variable' );
|
89 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR', 'blacklist-macro-datalayer-variable' );
|
90 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM', 'blacklist-macro-random-number' );
|
91 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER', 'blacklist-macro-referrer' );
|
92 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_URL', 'blacklist-macro-url' );
|
93 |
+
define( 'GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT', 'blacklist-macro-autoevent-variable' );
|
94 |
+
|
95 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
|
96 |
+
|
97 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE', 'integrate-woocommerce' );
|
98 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC', 'integrate-woocommerce-track-classic-ecommerce' );
|
99 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC', 'integrate-woocommerce-track-enhanced-ecommerce' );
|
100 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCREMARKETING', 'integrate-woocommerce-remarketing' );
|
101 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCUSESKU', 'integrate-woocommerce-remarketing-usesku' );
|
102 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH', 'integrate-woocommerce-use-full-category-path' );
|
103 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX', 'integrate-woocommerce-remarketing-productidprefix' );
|
104 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP', 'integrate-woocommerce-cart-as-first-step' );
|
105 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA', 'integrate-woocommerce-customer-data' );
|
106 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX', 'integrate-woocommerce-exclude-tax' );
|
107 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION', 'integrate-woocommerce-product-per-impression' );
|
108 |
+
define( 'GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG', 'integrate-woocommerce-do-not-use-order-tracked-flag' );
|
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', 'integrate-google-optimize-gaid' );
|
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', 0 );
|
119 |
+
define( 'GTM4WP_PLACEMENT_BODYOPEN', 1 );
|
120 |
+
define( 'GTM4WP_PLACEMENT_BODYOPEN_AUTO', 2 );
|
121 |
+
define( 'GTM4WP_PLACEMENT_OFF', 3 );
|
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 => GTM4WP_PLACEMENT_FOOTER,
|
129 |
+
GTM4WP_OPTION_ENV_GTM_AUTH => "",
|
130 |
+
GTM4WP_OPTION_ENV_GTM_PREVIEW => "",
|
131 |
+
GTM4WP_OPTION_DONOTTRACK => false,
|
132 |
+
GTM4WP_OPTION_LOADEARLY => false,
|
133 |
+
|
134 |
+
GTM4WP_OPTION_INCLUDE_REMARKETING => false,
|
135 |
+
GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
|
136 |
+
GTM4WP_OPTION_INCLUDE_USERROLE => false,
|
137 |
+
GTM4WP_OPTION_INCLUDE_USERID => false,
|
138 |
+
GTM4WP_OPTION_INCLUDE_USEREMAIL => false,
|
139 |
+
GTM4WP_OPTION_INCLUDE_USERREGDATE => false,
|
140 |
+
GTM4WP_OPTION_INCLUDE_USERNAME => false,
|
141 |
+
GTM4WP_OPTION_INCLUDE_VISITOR_IP => false,
|
142 |
+
GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
|
143 |
+
GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
|
144 |
+
GTM4WP_OPTION_INCLUDE_TAGS => true,
|
145 |
+
GTM4WP_OPTION_INCLUDE_AUTHOR => true,
|
146 |
+
GTM4WP_OPTION_INCLUDE_AUTHORID => false,
|
147 |
+
GTM4WP_OPTION_INCLUDE_POSTDATE => false,
|
148 |
+
GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
|
149 |
+
GTM4WP_OPTION_INCLUDE_POSTCOUNT => false,
|
150 |
+
GTM4WP_OPTION_INCLUDE_POSTID => false,
|
151 |
+
GTM4WP_OPTION_INCLUDE_POSTFORMAT => false,
|
152 |
+
GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
|
153 |
+
GTM4WP_OPTION_INCLUDE_BROWSERDATA => false,
|
154 |
+
GTM4WP_OPTION_INCLUDE_OSDATA => false,
|
155 |
+
GTM4WP_OPTION_INCLUDE_DEVICEDATA => false,
|
156 |
+
GTM4WP_OPTION_INCLUDE_MISCGEO => false,
|
157 |
+
GTM4WP_OPTION_INCLUDE_MISCGEOAPI => '',
|
158 |
+
GTM4WP_OPTION_INCLUDE_WEATHER => false,
|
159 |
+
GTM4WP_OPTION_INCLUDE_WEATHERUNITS => 0,
|
160 |
+
GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => '',
|
161 |
+
GTM4WP_OPTION_INCLUDE_SITEID => false,
|
162 |
+
GTM4WP_OPTION_INCLUDE_SITENAME => false,
|
163 |
+
|
164 |
+
GTM4WP_OPTION_EVENTS_OUTBOUND => false,
|
165 |
+
GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
|
166 |
+
GTM4WP_OPTION_EVENTS_DWLEXT => "pdf,doc,docx,xls,xlsx,ppt,pptx,zip,rar,gz,tar",
|
167 |
+
GTM4WP_OPTION_EVENTS_EMAILCLICKS => false,
|
168 |
+
GTM4WP_OPTION_EVENTS_SOCIAL => false,
|
169 |
+
|
170 |
+
GTM4WP_OPTION_EVENTS_FORMMOVE => true,
|
171 |
+
GTM4WP_OPTION_EVENTS_NEWUSERREG => false,
|
172 |
+
GTM4WP_OPTION_EVENTS_USERLOGIN => false,
|
173 |
+
|
174 |
+
GTM4WP_OPTION_EVENTS_YOUTUBE => false,
|
175 |
+
GTM4WP_OPTION_EVENTS_VIMEO => false,
|
176 |
+
GTM4WP_OPTION_EVENTS_SOUNDCLOUD => false,
|
177 |
+
|
178 |
+
GTM4WP_OPTION_SCROLLER_ENABLED => false,
|
179 |
+
GTM4WP_OPTION_SCROLLER_DEBUGMODE => false,
|
180 |
+
GTM4WP_OPTION_SCROLLER_CALLBACKTIME => 100,
|
181 |
+
GTM4WP_OPTION_SCROLLER_DISTANCE => 150,
|
182 |
+
GTM4WP_OPTION_SCROLLER_CONTENTID => "content",
|
183 |
+
GTM4WP_OPTION_SCROLLER_READERTIME => 60,
|
184 |
+
|
185 |
+
GTM4WP_OPTION_BLACKLIST_ENABLE => 0,
|
186 |
+
GTM4WP_OPTION_BLACKLIST_ADADVISOR => false,
|
187 |
+
GTM4WP_OPTION_BLACKLIST_ADROLL => false,
|
188 |
+
GTM4WP_OPTION_BLACKLIST_AWCONV => false,
|
189 |
+
GTM4WP_OPTION_BLACKLIST_AWREMARKET => false,
|
190 |
+
GTM4WP_OPTION_BLACKLIST_BIZO => false,
|
191 |
+
GTM4WP_OPTION_BLACKLIST_CLICKTALE => false,
|
192 |
+
GTM4WP_OPTION_BLACKLIST_COMSCORE => false,
|
193 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMHTML => false,
|
194 |
+
GTM4WP_OPTION_BLACKLIST_CUSTOMIMG => false,
|
195 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT => false,
|
196 |
+
GTM4WP_OPTION_BLACKLIST_DBLCLKSALES => false,
|
197 |
+
GTM4WP_OPTION_BLACKLIST_GACLASSIC => false,
|
198 |
+
GTM4WP_OPTION_BLACKLIST_MARIN => false,
|
199 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME => false,
|
200 |
+
GTM4WP_OPTION_BLACKLIST_MPLEXROI => false,
|
201 |
+
GTM4WP_OPTION_BLACKLIST_MEDIA6DEG => false,
|
202 |
+
GTM4WP_OPTION_BLACKLIST_TURNCONV => false,
|
203 |
+
GTM4WP_OPTION_BLACKLIST_TURNDATA => false,
|
204 |
+
GTM4WP_OPTION_BLACKLIST_UA => false,
|
205 |
+
|
206 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT => true,
|
207 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS => true,
|
208 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT => true,
|
209 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE => true,
|
210 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME => true,
|
211 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR => true,
|
212 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR => true,
|
213 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM => true,
|
214 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER => true,
|
215 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_URL => true,
|
216 |
+
GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT => true,
|
217 |
+
|
218 |
+
GTM4WP_OPTION_INTEGRATE_WPCF7 => false,
|
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 |
+
GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION => 0,
|
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 => false,
|
237 |
+
|
238 |
+
GTM4WP_OPTION_INTEGRATE_AMPID => ""
|
239 |
+
);
|
240 |
+
|
241 |
+
function gtm4wp_reload_options() {
|
242 |
+
global $gtm4wp_defaultoptions;
|
243 |
+
|
244 |
+
$storedoptions = (array) get_option( GTM4WP_OPTIONS );
|
245 |
+
if ( ! is_array( $gtm4wp_defaultoptions ) ) {
|
246 |
+
$gtm4wp_defaultoptions = array();
|
247 |
+
}
|
248 |
+
|
249 |
+
// update WooCommerce settings from 0.7.x to 0.8
|
250 |
+
if ( isset( $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ] ) && ! isset( $storedoptions[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) ) {
|
251 |
+
$storedoptions[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] = $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ];
|
252 |
+
$storedoptions[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] = false;
|
253 |
+
$storedoptions[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] = $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ];
|
254 |
+
|
255 |
+
unset( $storedoptions[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ] );
|
256 |
+
}
|
257 |
+
|
258 |
+
return array_merge( $gtm4wp_defaultoptions, $storedoptions );
|
259 |
+
}
|
260 |
+
|
261 |
+
function gtp4wp_debug_file( $debug_data ) {
|
262 |
+
$fp = fopen( dirname( __FILE__ ) . "/" . date("Y-m-d-H-i-s-u") . ".txt", "w" );
|
263 |
+
if ( $fp ) {
|
264 |
+
fwrite( $fp, $debug_data );
|
265 |
+
fclose( $fp );
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
$gtm4wp_options = gtm4wp_reload_options();
|
css/admin-gtm4wp.css
CHANGED
@@ -46,27 +46,27 @@
|
|
46 |
.gtm4wp-phase-beta,
|
47 |
.gtm4wp-phase-experimental,
|
48 |
.gtm4wp-phase-deprecated {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
}
|
56 |
|
57 |
.gtm4wp-phase-beta:before {
|
58 |
-
|
59 |
}
|
60 |
|
61 |
.gtm4wp-phase-deprecated {
|
62 |
-
|
63 |
-
|
64 |
}
|
65 |
|
66 |
.gtm4wp-phase-experimental:before {
|
67 |
-
|
68 |
}
|
69 |
|
70 |
.gtm4wp-phase-deprecated:before {
|
71 |
-
|
72 |
-
}
|
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,31 +1,31 @@
|
|
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
|
8 |
-
Author URI: https://gtm4wp.com/
|
9 |
-
Text Domain: duracelltomi-google-tag-manager
|
10 |
-
Domain Path: /languages
|
11 |
-
|
12 |
-
WC requires at least: 2.6
|
13 |
-
WC tested up to: 3.4.
|
14 |
-
*/
|
15 |
-
|
16 |
-
define( 'GTM4WP_VERSION', '1.
|
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');
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Google Tag Manager for Wordpress
|
4 |
+
Version: 1.9
|
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
|
8 |
+
Author URI: https://gtm4wp.com/
|
9 |
+
Text Domain: duracelltomi-google-tag-manager
|
10 |
+
Domain Path: /languages
|
11 |
+
|
12 |
+
WC requires at least: 2.6
|
13 |
+
WC tested up to: 3.4.5
|
14 |
+
*/
|
15 |
+
|
16 |
+
define( 'GTM4WP_VERSION', '1.9' );
|
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
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
25 |
+
/**
|
26 |
+
* Check if we are running AMP
|
27 |
+
*
|
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 |
+
}
|
35 |
+
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Pre-injection Check AMP Project's AMP Analytics tag, using amp-wp hook
|
41 |
+
*
|
42 |
+
* @link https://github.com/Automattic/amp-wp/blob/develop/includes/amp-post-template-actions.php
|
43 |
+
* @author Vincent Koc <https://github.com/koconder/>
|
44 |
+
* @return array Returns AMP Analytics array used by amp-wp
|
45 |
+
*/
|
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[ 'amp_component_scripts' ][ 'amp-analytics' ] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js';
|
53 |
+
$gtm4wp_amp_headerinjected = true;
|
54 |
+
|
55 |
+
// Manually load into AMP-WP Plugin
|
56 |
+
} else {
|
57 |
+
// Inject manually based on AMP <head> hook
|
58 |
+
add_action( 'amp_post_template_head', 'gtm4wp_amp_gtmampcode_injecthead' );
|
59 |
+
}
|
60 |
+
|
61 |
+
// Return the $data back to amp-wp hook
|
62 |
+
return $data;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Post-check AMP Project's AMP Analytics tag, using amp-wp hook
|
67 |
+
*
|
68 |
+
* @link https://github.com/Automattic/amp-wp/blob/develop/includes/amp-post-template-actions.php
|
69 |
+
* @author Vincent Koc <https://github.com/koconder/>
|
70 |
+
*/
|
71 |
+
function gtm4wp_amp_gtmampcode_injecthead() {
|
72 |
+
global $gtm4wp_amp_headerinjected;
|
73 |
+
|
74 |
+
$gtm4wp_amp_headerinjected = true;
|
75 |
+
echo '<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>';
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Generate AMP ready Google Tag Manager code
|
80 |
+
*
|
81 |
+
* @author Vincent Koc <https://github.com/koconder/>
|
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 = explode( ",", $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_AMPID ] );
|
92 |
+
$gtm4wp_ampid_list = array();
|
93 |
+
|
94 |
+
// Counter used for status return
|
95 |
+
$x = 0;
|
96 |
+
|
97 |
+
// Check we have more than one valid Google Tag Manager ID
|
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='.$gtm4wp_oneampid.'>m.url=SOURCE_URL" data-credentials="include">'.gtm4wp_amp_gtmvariables().'</amp-analytics>';
|
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 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
// No injection has occured
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Generate the AMP "vars" from the GTM dataLayer
|
127 |
+
*
|
128 |
+
* @author Vincent Koc <https://github.com/koconder/>
|
129 |
+
* @return string Returns json dataLayer for AMP code
|
130 |
+
*/
|
131 |
+
function gtm4wp_amp_gtmvariables() {
|
132 |
+
global $gtm4wp_datalayer_json;
|
133 |
+
return '{"vars":{'.$gtm4wp_datalayer_json."} }";
|
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 amp_post_template_body
|
148 |
+
//(https://github.com/Automattic/amp-wp/pull/1143)
|
149 |
+
//add_action( 'amp_post_template_body', 'gtm4wp_amp_gtmcode');
|
150 |
+
|
151 |
+
// Publish the GTM code and dataLayer to the footer
|
152 |
+
add_action( 'amp_post_template_footer', 'gtm4wp_amp_gtmcode');
|
integration/google-optimize.php
CHANGED
@@ -1,28 +1,61 @@
|
|
1 |
-
<?php
|
2 |
-
function gtm4wp_go_pagehiding_snippet() {
|
3 |
-
global $gtm4wp_options;
|
4 |
-
|
5 |
-
$gtm4wp_goids = explode( ",", $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] );
|
6 |
-
$
|
7 |
-
if ( count( $gtm4wp_goids ) > 0 ) {
|
8 |
-
foreach( $gtm4wp_goids as $gtm4wp_onegoid ) {
|
9 |
-
$
|
10 |
-
}
|
11 |
-
|
12 |
-
$gtm4wp_gotimeout = (int) $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ];
|
13 |
-
if ( 0 == $gtm4wp_gotimeout ) {
|
14 |
-
$gtm4wp_gotimeout = 4000;
|
15 |
-
}
|
16 |
-
|
17 |
-
echo "
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
(a
|
22 |
-
}
|
23 |
-
(
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
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 |
+
|
12 |
+
$gtm4wp_gotimeout = (int) $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ];
|
13 |
+
if ( 0 == $gtm4wp_gotimeout ) {
|
14 |
+
$gtm4wp_gotimeout = 4000;
|
15 |
+
}
|
16 |
+
|
17 |
+
echo "
|
18 |
+
<!-- GTM4WP: Google Optimize Page Hiding snippet -->
|
19 |
+
<style>.google-optimize-hide { opacity: 0 !important} </style>
|
20 |
+
<script data-cfasync=\"false\">
|
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 |
+
|
44 |
+
$content .= "
|
45 |
+
<!-- GTM4WP: Load Google Optimize containers -->
|
46 |
+
<script>
|
47 |
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
48 |
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
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,33 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
if ( false === strpos( $return, ' id="' ) ) {
|
8 |
-
if ( preg_match('/src="([^\"]+?)"/i', $return, $r) ) {
|
9 |
-
$_urlquery = parse_url( $r[1], PHP_URL_QUERY );
|
10 |
-
if ( false !== $_urlquery ) {
|
11 |
-
parse_str( $_urlquery, $_urlparts );
|
12 |
-
|
13 |
-
if ( isset( $_urlparts[ "url" ] ) ) {
|
14 |
-
$_urlpartsid = explode( "/", $_urlparts[ "url" ] );
|
15 |
-
$_playerid = "soundcloudplayer_" . $_urlpartsid[ count( $_urlpartsid )-1 ];
|
16 |
-
$return = str_replace( '<iframe ', '<iframe id="' . $_playerid . '" ', $return);
|
17 |
-
}
|
18 |
-
}
|
19 |
-
}
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
return $return;
|
24 |
-
}
|
25 |
-
|
26 |
-
add_filter( "oembed_result", "gtm4wp_soundcloud", 10, 3 );
|
27 |
-
*/
|
28 |
-
|
29 |
-
if ( ! is_admin() ) {
|
30 |
-
$in_footer = apply_filters( 'gtm4wp_soundcloud', false);
|
31 |
-
wp_enqueue_script( "gtm4wp-soundcloud-api", "https://w.soundcloud.com/player/api.js", array(), "1.0", $in_footer );
|
32 |
-
wp_enqueue_script( "gtm4wp-soundcloud", $gtp4wp_plugin_url . "js/gtm4wp-soundcloud.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
33 |
-
}
|
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,28 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
$_urlparts = explode( "/", $url );
|
9 |
-
$_playerid = "vimeoplayer_" . $_urlparts[ count( $_urlparts )-1 ];
|
10 |
-
|
11 |
-
$return = str_replace( '<iframe ', '<iframe id="' . $_playerid . '" ', $return);
|
12 |
-
$return = str_replace( $url, $url . "?api=1&origin=" . site_url() . "&player_id=" . $_playerid, $return);
|
13 |
-
} else {
|
14 |
-
$return = str_replace( $url, $url . "?api=1&origin=" . site_url(), $return);
|
15 |
-
}
|
16 |
-
}
|
17 |
-
|
18 |
-
return $return;
|
19 |
-
}
|
20 |
-
|
21 |
-
add_filter( "oembed_result", "gtm4wp_vimeo", 10, 3 );
|
22 |
-
*/
|
23 |
-
if ( ! is_admin() ) {
|
24 |
-
$in_footer = apply_filters( 'gtm4wp_vimeo', false);
|
25 |
-
// wp_enqueue_script( "gtm4wp-vimeo-froogaloop", $gtp4wp_plugin_url . "js/froogaloop.js", array(), "2.0", $in_footer );
|
26 |
-
wp_enqueue_script( "gtm4wp-vimeo-api", "https://player.vimeo.com/api/player.js", array(), "1.0", $in_footer );
|
27 |
-
wp_enqueue_script( "gtm4wp-vimeo", $gtp4wp_plugin_url . "js/gtm4wp-vimeo.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
28 |
-
}
|
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,1304 +1,1390 @@
|
|
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 );
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
)
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
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 |
-
|
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 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
}
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
$
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
$
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
);
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
$dataLayer["
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
if ( $
|
429 |
-
$
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
$
|
454 |
-
$
|
455 |
-
|
456 |
-
|
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 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
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 |
-
|
529 |
-
|
530 |
-
|
531 |
-
$(
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
}
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
}
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
(
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
}
|
896 |
-
}
|
897 |
-
|
898 |
-
if (
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
var
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
'
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
}
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
$
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
$_temp_productdata =
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
$
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
)
|
1074 |
-
|
1075 |
-
$
|
1076 |
-
|
1077 |
-
$
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
}
|
1091 |
-
|
1092 |
-
function
|
1093 |
-
global $woocommerce_loop;
|
1094 |
-
|
1095 |
-
$woocommerce_loop[ "listtype" ] = __( "
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
$woocommerce_loop
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
$
|
1114 |
-
}
|
1115 |
-
|
1116 |
-
function
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
$
|
1162 |
-
}
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
$
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
$
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
$
|
1214 |
-
|
1215 |
-
)
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
}
|
1230 |
-
|
1231 |
-
$
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
21 |
+
}
|
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;
|
57 |
+
}
|
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( $category_id, 'product_cat', array(
|
71 |
+
"format" => "name",
|
72 |
+
"separator" => "/",
|
73 |
+
"link" => false,
|
74 |
+
"inclusive" => true
|
75 |
+
));
|
76 |
+
|
77 |
+
if ( is_string( $category_parent_list ) ) {
|
78 |
+
$cat_hierarchy = trim( $category_parent_list, '/' );
|
79 |
+
}
|
80 |
+
|
81 |
+
return $cat_hierarchy;
|
82 |
+
}
|
83 |
+
|
84 |
+
function gtm4wp_get_product_category( $product_id, $fullpath = false) {
|
85 |
+
$product_cat = "";
|
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 );
|
92 |
+
} else {
|
93 |
+
$product_cat = $first_product_cat->name;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $product_cat;
|
98 |
+
}
|
99 |
+
|
100 |
+
function gtm4wp_woocommerce_addglobalvars($return = '') {
|
101 |
+
global $gtm4wp_options;
|
102 |
+
|
103 |
+
$return .= "
|
104 |
+
var gtm4wp_use_sku_instead = " . (int)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ]) . ";
|
105 |
+
var gtm4wp_id_prefix = '" . esc_js( gtm4wp_prefix_productid("") ) . "';
|
106 |
+
var gtm4wp_remarketing = " . gtm4wp_escjs_boolean((boolean)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ])) . ";
|
107 |
+
var gtm4wp_eec = " . gtm4wp_escjs_boolean((boolean)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ])) . ";
|
108 |
+
var gtm4wp_classicec = " . gtm4wp_escjs_boolean((boolean)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ])) . ";
|
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 |
+
}
|
114 |
+
|
115 |
+
function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
116 |
+
global $gtm4wp_options, $wp_query, $gtm4wp_datalayer_name, $gtm4wp_product_counter, $gtm4wp_is_woocommerce3;
|
117 |
+
|
118 |
+
$woo = WC();
|
119 |
+
|
120 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA ] && $gtm4wp_is_woocommerce3 ) {
|
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["customerTotalOrders"] = $woo_customer->get_order_count();
|
125 |
+
$dataLayer["customerTotalOrderValue"] = $woo_customer->get_total_spent();
|
126 |
+
|
127 |
+
$dataLayer["customerFirstName"] = $woo_customer->get_first_name();
|
128 |
+
$dataLayer["customerLastName"] = $woo_customer->get_last_name();
|
129 |
+
|
130 |
+
$dataLayer["customerBillingFirstName"] = $woo_customer->get_billing_first_name();
|
131 |
+
$dataLayer["customerBillingLastName"] = $woo_customer->get_billing_last_name();
|
132 |
+
$dataLayer["customerBillingCompany"] = $woo_customer->get_billing_company();
|
133 |
+
$dataLayer["customerBillingAddress1"] = $woo_customer->get_billing_address_1();
|
134 |
+
$dataLayer["customerBillingAddress2"] = $woo_customer->get_billing_address_2();
|
135 |
+
$dataLayer["customerBillingCity"] = $woo_customer->get_billing_city();
|
136 |
+
$dataLayer["customerBillingPostcode"] = $woo_customer->get_billing_postcode();
|
137 |
+
$dataLayer["customerBillingCountry"] = $woo_customer->get_billing_country();
|
138 |
+
$dataLayer["customerBillingEmail"] = $woo_customer->get_billing_email();
|
139 |
+
$dataLayer["customerBillingPhone"] = $woo_customer->get_billing_phone();
|
140 |
+
|
141 |
+
$dataLayer["customerShippingFirstName"] = $woo_customer->get_shipping_first_name();
|
142 |
+
$dataLayer["customerShippingLastName"] = $woo_customer->get_shipping_last_name();
|
143 |
+
$dataLayer["customerShippingCompany"] = $woo_customer->get_shipping_company();
|
144 |
+
$dataLayer["customerShippingAddress1"] = $woo_customer->get_shipping_address_1();
|
145 |
+
$dataLayer["customerShippingAddress2"] = $woo_customer->get_shipping_address_2();
|
146 |
+
$dataLayer["customerShippingCity"] = $woo_customer->get_shipping_city();
|
147 |
+
$dataLayer["customerShippingPostcode"] = $woo_customer->get_shipping_postcode();
|
148 |
+
$dataLayer["customerShippingCountry"] = $woo_customer->get_shipping_country();
|
149 |
+
}
|
150 |
+
|
151 |
+
if ( is_product_category() || is_product_tag() || is_front_page() || is_shop() ) {
|
152 |
+
$ecomm_pagetype = "category";
|
153 |
+
if ( is_front_page() ) {
|
154 |
+
$ecomm_pagetype = "home";
|
155 |
+
} else if ( is_search() ) {
|
156 |
+
$ecomm_pagetype = "searchresults";
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
160 |
+
$dataLayer["ecomm_prodid"] = array();
|
161 |
+
$dataLayer["ecomm_pagetype"] = $ecomm_pagetype;
|
162 |
+
$dataLayer["ecomm_totalvalue"] = 0;
|
163 |
+
}
|
164 |
+
} else if ( is_product() ) {
|
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 );
|
168 |
+
$product_id = $product->get_id();
|
169 |
+
|
170 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
171 |
+
|
172 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) {
|
173 |
+
$product_sku = $product->get_sku();
|
174 |
+
if ( "" != $product_sku ) {
|
175 |
+
$product_id = $product_sku;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$remarketing_id = (string)$product_id;
|
179 |
+
$product_price = $product->get_price();
|
180 |
+
|
181 |
+
if ( "variable" != $product->get_type() ) {
|
182 |
+
$dataLayer["productIsVariable"] = 0;
|
183 |
+
|
184 |
+
$_temp_productdata = array(
|
185 |
+
"name" => gtm4wp_woocommerce_html_entity_decode( get_the_title() ),
|
186 |
+
"id" => $product_id,
|
187 |
+
"price" => $product_price,
|
188 |
+
"category" => $product_cat,
|
189 |
+
"stocklevel" => $product->get_stock_quantity()
|
190 |
+
);
|
191 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "productdetail" );
|
192 |
+
|
193 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
194 |
+
$dataLayer["ecomm_prodid"] = gtm4wp_prefix_productid( $remarketing_id );
|
195 |
+
$dataLayer["ecomm_pagetype"] = "product";
|
196 |
+
$dataLayer["ecomm_totalvalue"] = (float)$eec_product_array[ "price" ];
|
197 |
+
}
|
198 |
+
|
199 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
200 |
+
$dataLayer["ecommerce"] = array(
|
201 |
+
"detail" => array(
|
202 |
+
"products" => array($eec_product_array)
|
203 |
+
)
|
204 |
+
);
|
205 |
+
}
|
206 |
+
} else {
|
207 |
+
$dataLayer["productIsVariable"] = 1;
|
208 |
+
|
209 |
+
$dataLayer["ecomm_prodid"] = gtm4wp_prefix_productid( $remarketing_id );
|
210 |
+
$dataLayer["ecomm_pagetype"] = "product";
|
211 |
+
$dataLayer["ecomm_totalvalue"] = $product_price;
|
212 |
+
}
|
213 |
+
}
|
214 |
+
} else if ( is_cart() ) {
|
215 |
+
// moved to gtm4wp-woocommerce-enhanced.js
|
216 |
+
/*
|
217 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
218 |
+
gtm4wp_woocommerce_addjs("
|
219 |
+
$( document ).on( 'click', '[name=update_cart]', function() {
|
220 |
+
gtm4wp_handle_cart_qty_change();
|
221 |
+
});
|
222 |
+
|
223 |
+
$( document ).on( 'keypress', '.woocommerce-cart-form input[type=number]', function() {
|
224 |
+
gtm4wp_handle_cart_qty_change();
|
225 |
+
});
|
226 |
+
|
227 |
+
function gtm4wp_handle_cart_qty_change() {
|
228 |
+
$( '.product-quantity input.qty' ).each(function() {
|
229 |
+
var _original_value = $( this ).prop( 'defaultValue' );
|
230 |
+
|
231 |
+
var _current_value = parseInt( $( this ).val() );
|
232 |
+
if ( isNaN( _current_value ) ) {
|
233 |
+
_current_value = _original_value;
|
234 |
+
}
|
235 |
+
|
236 |
+
if ( _original_value != _current_value ) {
|
237 |
+
var productdata = $( this ).closest( '.cart_item' ).find( '.remove' );
|
238 |
+
|
239 |
+
if ( _original_value < _current_value ) {
|
240 |
+
". $gtm4wp_datalayer_name .".push({
|
241 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
242 |
+
'ecommerce': {
|
243 |
+
'currencyCode': '".get_woocommerce_currency()."',
|
244 |
+
'add': {
|
245 |
+
'products': [{
|
246 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
247 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
248 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
249 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
250 |
+
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
251 |
+
'quantity': _current_value - _original_value
|
252 |
+
}]
|
253 |
+
}
|
254 |
+
}
|
255 |
+
});
|
256 |
+
} else {
|
257 |
+
". $gtm4wp_datalayer_name .".push({
|
258 |
+
'event': 'gtm4wp.removeFromCartEEC',
|
259 |
+
'ecommerce': {
|
260 |
+
'currencyCode': '".get_woocommerce_currency()."',
|
261 |
+
'remove': {
|
262 |
+
'products': [{
|
263 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
264 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
265 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
266 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
267 |
+
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
268 |
+
'quantity': _original_value - _current_value
|
269 |
+
}]
|
270 |
+
}
|
271 |
+
}
|
272 |
+
});
|
273 |
+
}
|
274 |
+
} // end if qty changed
|
275 |
+
}); // end each qty field
|
276 |
+
}; // end gtm4wp_handle_cart_qty_change()
|
277 |
+
");
|
278 |
+
}
|
279 |
+
*/
|
280 |
+
|
281 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] || $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
282 |
+
$gtm4wp_cart_products = array();
|
283 |
+
$gtm4wp_cart_products_remarketing = array();
|
284 |
+
|
285 |
+
foreach( $woo->cart->get_cart() as $cart_item_id => $cart_item_data) {
|
286 |
+
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data["data"], $cart_item_data, $cart_item_id );
|
287 |
+
|
288 |
+
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
289 |
+
continue;
|
290 |
+
}
|
291 |
+
|
292 |
+
$product_id = $product->get_id();
|
293 |
+
$product_type = $product->get_type();
|
294 |
+
|
295 |
+
if ( "variation" == $product_type ) {
|
296 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
297 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
298 |
+
} else {
|
299 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
300 |
+
}
|
301 |
+
|
302 |
+
$remarketing_id = $product_id;
|
303 |
+
$product_sku = $product->get_sku();
|
304 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
305 |
+
$remarketing_id = $product_sku;
|
306 |
+
}
|
307 |
+
|
308 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
309 |
+
$_temp_productdata = array(
|
310 |
+
"id" => $remarketing_id,
|
311 |
+
"name" => $product->get_title(),
|
312 |
+
"price" => $product->get_price(),
|
313 |
+
"category" => $product_cat,
|
314 |
+
"stocklevel" => $product->get_stock_quantity(),
|
315 |
+
"quantity" => $cart_item_data["quantity"]
|
316 |
+
);
|
317 |
+
|
318 |
+
if ( "variation" == $product_type ) {
|
319 |
+
$_temp_productdata[ "variant" ] = implode(",", $product->get_variation_attributes());
|
320 |
+
}
|
321 |
+
|
322 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "cart" );
|
323 |
+
$gtm4wp_cart_products[] = $eec_product_array;
|
324 |
+
}
|
325 |
+
|
326 |
+
$gtm4wp_cart_products_remarketing[] = gtm4wp_prefix_productid( $remarketing_id );
|
327 |
+
}
|
328 |
+
|
329 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
330 |
+
$dataLayer["ecomm_prodid"] = $gtm4wp_cart_products_remarketing;
|
331 |
+
$dataLayer["ecomm_pagetype"] = "cart";
|
332 |
+
if ( ! $woo->cart->prices_include_tax ) {
|
333 |
+
$cart_total = $woo->cart->cart_contents_total;
|
334 |
+
} else {
|
335 |
+
$cart_total = $woo->cart->cart_contents_total + $woo->cart->tax_total;
|
336 |
+
}
|
337 |
+
$dataLayer["ecomm_totalvalue"] = (float)$cart_total;
|
338 |
+
}
|
339 |
+
|
340 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] ) {
|
341 |
+
$dataLayer["ecommerce"] = array(
|
342 |
+
"checkout" => array(
|
343 |
+
"actionField" => array(
|
344 |
+
"step" => 1
|
345 |
+
),
|
346 |
+
"products" => $gtm4wp_cart_products
|
347 |
+
)
|
348 |
+
);
|
349 |
+
}
|
350 |
+
}
|
351 |
+
} else if ( is_order_received_page() ) {
|
352 |
+
$do_not_flag_tracked_order = (boolean)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG ]);
|
353 |
+
$order_id = empty( $_GET[ "order" ] ) ? ( $GLOBALS[ "wp" ]->query_vars[ "order-received" ] ? $GLOBALS[ "wp" ]->query_vars[ "order-received" ] : 0 ) : absint( $_GET[ "order" ] );
|
354 |
+
$order_id_filtered = apply_filters( 'woocommerce_thankyou_order_id', $order_id );
|
355 |
+
if ( "" != $order_id_filtered ) {
|
356 |
+
$order_id = $order_id_filtered;
|
357 |
+
}
|
358 |
+
|
359 |
+
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET[ "key" ] ) ? "" : wc_clean( $_GET[ "key" ] ) );
|
360 |
+
|
361 |
+
if ( $order_id > 0 ) {
|
362 |
+
$order = wc_get_order( $order_id );
|
363 |
+
|
364 |
+
if ( $order instanceof WC_Order ) {
|
365 |
+
if ( $gtm4wp_is_woocommerce3 ) {
|
366 |
+
$this_order_key = $order->get_order_key();
|
367 |
+
} else {
|
368 |
+
$this_order_key = $order->order_key;
|
369 |
+
}
|
370 |
+
|
371 |
+
if ( $this_order_key != $order_key ) {
|
372 |
+
unset( $order );
|
373 |
+
}
|
374 |
+
} else {
|
375 |
+
unset( $order );
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
if ( ( 1 == get_post_meta( $order_id, '_ga_tracked', true ) ) && !$do_not_flag_tracked_order ) {
|
380 |
+
unset( $order );
|
381 |
+
}
|
382 |
+
|
383 |
+
if ( isset( $order ) ) {
|
384 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX ] ) {
|
385 |
+
$order_revenue = $order->get_total() - $order->get_total_tax();
|
386 |
+
} else {
|
387 |
+
$order_revenue = $order->get_total();
|
388 |
+
}
|
389 |
+
|
390 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
391 |
+
$dataLayer["transactionId"] = $order->get_order_number();
|
392 |
+
$dataLayer["transactionDate"] = date("c");
|
393 |
+
$dataLayer["transactionType"] = "sale";
|
394 |
+
$dataLayer["transactionAffiliation"] = "";
|
395 |
+
$dataLayer["transactionTotal"] = $order_revenue;
|
396 |
+
if ( $gtm4wp_is_woocommerce3 ) {
|
397 |
+
$dataLayer["transactionShipping"] = $order->get_shipping_total();
|
398 |
+
} else {
|
399 |
+
$dataLayer["transactionShipping"] = $order->get_total_shipping();
|
400 |
+
}
|
401 |
+
$dataLayer["transactionTax"] = $order->get_total_tax();
|
402 |
+
$dataLayer["transactionPaymentType"] = ( $gtm4wp_is_woocommerce3 ? $order->get_payment_method_title() : $order->payment_method_title);
|
403 |
+
$dataLayer["transactionCurrency"] = get_woocommerce_currency();
|
404 |
+
$dataLayer["transactionShippingMethod"] = $order->get_shipping_method();
|
405 |
+
$dataLayer["transactionPromoCode"] = implode( ", ", $order->get_used_coupons() );
|
406 |
+
}
|
407 |
+
|
408 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
409 |
+
$dataLayer["ecommerce"] = array(
|
410 |
+
"currencyCode" => get_woocommerce_currency(),
|
411 |
+
"purchase" => array(
|
412 |
+
"actionField" => array(
|
413 |
+
"id" => $order->get_order_number(),
|
414 |
+
"affiliation" => "",
|
415 |
+
"revenue" => $order_revenue,
|
416 |
+
"tax" => $order->get_total_tax(),
|
417 |
+
"shipping" => ( $gtm4wp_is_woocommerce3 ? $order->get_shipping_total() : $order->get_total_shipping()),
|
418 |
+
"coupon" => implode( ", ", $order->get_used_coupons() )
|
419 |
+
)
|
420 |
+
)
|
421 |
+
);
|
422 |
+
}
|
423 |
+
|
424 |
+
$_products = array();
|
425 |
+
$_sumprice = 0;
|
426 |
+
$_product_ids = array();
|
427 |
+
|
428 |
+
if ( $order->get_items() ) {
|
429 |
+
foreach ( $order->get_items() as $item ) {
|
430 |
+
|
431 |
+
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_ORDER_ITEM, true, $item ) ) {
|
432 |
+
continue;
|
433 |
+
}
|
434 |
+
|
435 |
+
$product = ( $gtm4wp_is_woocommerce3 ? $item->get_product() : $order->get_product_from_item( $item ) ) ;
|
436 |
+
|
437 |
+
$product_id = $product->get_id();
|
438 |
+
$product_type = $product->get_type();
|
439 |
+
|
440 |
+
if ( "variation" == $product_type ) {
|
441 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
442 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
443 |
+
} else {
|
444 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
445 |
+
}
|
446 |
+
|
447 |
+
$remarketing_id = $product_id;
|
448 |
+
$product_sku = $product->get_sku();
|
449 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
450 |
+
$remarketing_id = $product_sku;
|
451 |
+
}
|
452 |
+
|
453 |
+
$product_price = $order->get_item_total( $item );
|
454 |
+
$_temp_productdata = array(
|
455 |
+
"id" => $remarketing_id,
|
456 |
+
"name" => $product->get_title(),
|
457 |
+
"sku" => $product_sku ? $product_sku : $product_id,
|
458 |
+
"category" => $product_cat,
|
459 |
+
"price" => $product_price,
|
460 |
+
"currency" => get_woocommerce_currency(),
|
461 |
+
"stocklevel" => $product->get_stock_quantity(),
|
462 |
+
"quantity" => $item['qty']
|
463 |
+
);
|
464 |
+
|
465 |
+
if ( "variation" == $product_type ) {
|
466 |
+
$_temp_productdata[ "variant" ] = implode(",", $product->get_variation_attributes());
|
467 |
+
}
|
468 |
+
|
469 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "purchase" );
|
470 |
+
$_products[] = $eec_product_array;
|
471 |
+
|
472 |
+
$_sumprice += $product_price * $eec_product_array[ "quantity" ];
|
473 |
+
$_product_ids[] = gtm4wp_prefix_productid( $remarketing_id );
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
478 |
+
$dataLayer["transactionProducts"] = $_products;
|
479 |
+
$dataLayer["event"] = "gtm4wp.orderCompleted";
|
480 |
+
}
|
481 |
+
|
482 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
483 |
+
$dataLayer["ecommerce"]["purchase"]["products"] = $_products;
|
484 |
+
$dataLayer["event"] = "gtm4wp.orderCompletedEEC";
|
485 |
+
}
|
486 |
+
|
487 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
488 |
+
$dataLayer["ecomm_prodid"] = $_product_ids;
|
489 |
+
$dataLayer["ecomm_pagetype"] = "purchase";
|
490 |
+
$dataLayer["ecomm_totalvalue"] = (float)$_sumprice;
|
491 |
+
}
|
492 |
+
|
493 |
+
if ( !$do_not_flag_tracked_order ) {
|
494 |
+
update_post_meta( $order_id, '_ga_tracked', 1 );
|
495 |
+
}
|
496 |
+
}
|
497 |
+
} else if ( is_checkout() ) {
|
498 |
+
if ( ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) ) {
|
499 |
+
$gtm4wp_checkout_products = array();
|
500 |
+
$gtm4wp_checkout_products_remarketing = array();
|
501 |
+
$gtm4wp_totalvalue = 0;
|
502 |
+
|
503 |
+
foreach( $woo->cart->get_cart() as $cart_item_id => $cart_item_data) {
|
504 |
+
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item_data["data"], $cart_item_data, $cart_item_id );
|
505 |
+
|
506 |
+
if ( ! apply_filters( GTM4WP_WPFILTER_EEC_CART_ITEM, true, $cart_item_data ) ) {
|
507 |
+
continue;
|
508 |
+
}
|
509 |
+
|
510 |
+
$product_id = $product->get_id();
|
511 |
+
$product_type = $product->get_type();
|
512 |
+
|
513 |
+
if ( "variation" == $product_type ) {
|
514 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
515 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
516 |
+
} else {
|
517 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
518 |
+
}
|
519 |
+
|
520 |
+
$remarketing_id = $product_id;
|
521 |
+
$product_sku = $product->get_sku();
|
522 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
523 |
+
$remarketing_id = $product_sku;
|
524 |
+
}
|
525 |
+
|
526 |
+
$_temp_productdata = array(
|
527 |
+
"id" => $remarketing_id,
|
528 |
+
"name" => $product->get_title(),
|
529 |
+
"price" => $product->get_price(),
|
530 |
+
"category" => $product_cat,
|
531 |
+
"stocklevel" => $product->get_stock_quantity(),
|
532 |
+
"quantity" => $cart_item_data["quantity"]
|
533 |
+
);
|
534 |
+
|
535 |
+
if ( "variation" == $product_type ) {
|
536 |
+
$_temp_productdata[ "variant" ] = implode(",", $product->get_variation_attributes());
|
537 |
+
}
|
538 |
+
|
539 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "checkout" );
|
540 |
+
$gtm4wp_checkout_products[] = $eec_product_array;
|
541 |
+
|
542 |
+
$gtm4wp_checkout_products_remarketing[] = gtm4wp_prefix_productid( $remarketing_id );
|
543 |
+
$gtm4wp_totalvalue += $eec_product_array[ "quantity" ] * $eec_product_array[ "price" ];
|
544 |
+
} // end foreach cart item
|
545 |
+
|
546 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
547 |
+
$dataLayer["ecomm_prodid"] = $gtm4wp_checkout_products_remarketing;
|
548 |
+
$dataLayer["ecomm_pagetype"] = "cart";
|
549 |
+
$dataLayer["ecomm_totalvalue"] = (float)$gtm4wp_totalvalue;
|
550 |
+
}
|
551 |
+
|
552 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
553 |
+
$dataLayer["ecommerce"] = array(
|
554 |
+
"checkout" => array(
|
555 |
+
"actionField" => array(
|
556 |
+
"step" => 1 + (int)$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ]
|
557 |
+
),
|
558 |
+
"products" => $gtm4wp_checkout_products
|
559 |
+
)
|
560 |
+
);
|
561 |
+
|
562 |
+
gtm4wp_woocommerce_addjs("
|
563 |
+
var gtm4wp_checkout_products = " . json_encode($gtm4wp_checkout_products) . ";
|
564 |
+
var gtm4wp_checkout_step_offset = " . (int)$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] . ";");
|
565 |
+
|
566 |
+
// moved to gtm4wp-woocommerce-enhanced.js
|
567 |
+
/*
|
568 |
+
gtm4wp_woocommerce_addjs("
|
569 |
+
var gtm4wp_checkout_products = " . json_encode($gtm4wp_checkout_products) . ";
|
570 |
+
var gtm4wp_checkout_step_offset = " . (int)$gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP ] . ";
|
571 |
+
var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here
|
572 |
+
|
573 |
+
$( document ).on( 'blur', 'input[name^=shipping_]:not(input[name=shipping_method])', function() {
|
574 |
+
// do not report checkout step if already reported
|
575 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping' ) > -1 ) {
|
576 |
+
return;
|
577 |
+
}
|
578 |
+
|
579 |
+
// do not report checkout step if user is traversing through the section without filling in any data
|
580 |
+
if ( $( this ).val().trim() == '' ) {
|
581 |
+
return;
|
582 |
+
}
|
583 |
+
|
584 |
+
". $gtm4wp_datalayer_name .".push({
|
585 |
+
'event': 'gtm4wp.checkoutStepEEC',
|
586 |
+
'ecommerce': {
|
587 |
+
'checkout': {
|
588 |
+
'actionField': {
|
589 |
+
'step': 2 + gtm4wp_checkout_step_offset
|
590 |
+
},
|
591 |
+
'products': gtm4wp_checkout_products
|
592 |
+
}
|
593 |
+
}
|
594 |
+
});
|
595 |
+
|
596 |
+
gtm4wp_checkout_step_fired.push( 'shipping' );
|
597 |
+
});
|
598 |
+
|
599 |
+
$( document ).on( 'click', 'input[name=shipping_method]', function() {
|
600 |
+
// do not report checkout step if already reported
|
601 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) > -1 ) {
|
602 |
+
return;
|
603 |
+
}
|
604 |
+
|
605 |
+
// do not fire event during page load
|
606 |
+
if ( 'complete' != document.readyState ) {
|
607 |
+
return;
|
608 |
+
}
|
609 |
+
|
610 |
+
". $gtm4wp_datalayer_name .".push({
|
611 |
+
'event': 'gtm4wp.checkoutStepEEC',
|
612 |
+
'ecommerce': {
|
613 |
+
'checkout': {
|
614 |
+
'actionField': {
|
615 |
+
'step': 3 + gtm4wp_checkout_step_offset
|
616 |
+
},
|
617 |
+
'products': gtm4wp_checkout_products
|
618 |
+
}
|
619 |
+
}
|
620 |
+
});
|
621 |
+
|
622 |
+
gtm4wp_checkout_step_fired.push( 'shipping_method' );
|
623 |
+
});
|
624 |
+
|
625 |
+
$( document ).on( 'click', 'input[name=payment_method]', function() {
|
626 |
+
// do not report checkout step if already reported
|
627 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) > -1 ) {
|
628 |
+
return;
|
629 |
+
}
|
630 |
+
|
631 |
+
// do not fire event during page load
|
632 |
+
if ( 'complete' != document.readyState ) {
|
633 |
+
return;
|
634 |
+
}
|
635 |
+
|
636 |
+
". $gtm4wp_datalayer_name .".push({
|
637 |
+
'event': 'gtm4wp.checkoutStepEEC',
|
638 |
+
'ecommerce': {
|
639 |
+
'checkout': {
|
640 |
+
'actionField': {
|
641 |
+
'step': 4 + gtm4wp_checkout_step_offset
|
642 |
+
},
|
643 |
+
'products': gtm4wp_checkout_products
|
644 |
+
}
|
645 |
+
}
|
646 |
+
});
|
647 |
+
|
648 |
+
gtm4wp_checkout_step_fired.push( 'payment_method' );
|
649 |
+
});
|
650 |
+
|
651 |
+
$( 'form[name=checkout]' ).on( 'submit', function() {
|
652 |
+
console.log('form submit');
|
653 |
+
|
654 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) {
|
655 |
+
// shipping methods are not visible if only one is available
|
656 |
+
// and if the user has already a pre-selected method, no click event will fire to report the checkout step
|
657 |
+
$( 'input[name=shipping_method]:checked' ).trigger( 'click' );
|
658 |
+
|
659 |
+
gtm4wp_checkout_step_fired.push( 'shipping_method' );
|
660 |
+
}
|
661 |
+
|
662 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) == -1 ) {
|
663 |
+
// if the user has already a pre-selected method, no click event will fire to report the checkout step
|
664 |
+
$( 'input[name=payment_method]:checked' ).trigger( 'click' );
|
665 |
+
|
666 |
+
gtm4wp_checkout_step_fired.push( 'payment_method' );
|
667 |
+
}
|
668 |
+
|
669 |
+
var _shipping_el = $( '#shipping_method input:checked' );
|
670 |
+
if ( _shipping_el.length > 0 ) {
|
671 |
+
". $gtm4wp_datalayer_name .".push({
|
672 |
+
'event': 'gtm4wp.checkoutOptionEEC',
|
673 |
+
'ecommerce': {
|
674 |
+
'checkout_option': {
|
675 |
+
'actionField': {
|
676 |
+
'step': 3 + gtm4wp_checkout_step_offset,
|
677 |
+
'option': 'Shipping: ' + _shipping_el.val()
|
678 |
+
}
|
679 |
+
}
|
680 |
+
}
|
681 |
+
});
|
682 |
+
}
|
683 |
+
|
684 |
+
var _payment_el = $( '.payment_methods input:checked' );
|
685 |
+
if ( _payment_el.length > 0 ) {
|
686 |
+
". $gtm4wp_datalayer_name .".push({
|
687 |
+
'event': 'gtm4wp.checkoutOptionEEC',
|
688 |
+
'ecommerce': {
|
689 |
+
'checkout_option': {
|
690 |
+
'actionField': {
|
691 |
+
'step': 4 + gtm4wp_checkout_step_offset,
|
692 |
+
'option': 'Payment: ' + _payment_el.val()
|
693 |
+
}
|
694 |
+
}
|
695 |
+
}
|
696 |
+
});
|
697 |
+
}
|
698 |
+
});");
|
699 |
+
*/
|
700 |
+
}
|
701 |
+
}
|
702 |
+
} else {
|
703 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
704 |
+
$dataLayer["ecomm_pagetype"] = "other";
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
// moved to gtm4wp-woocommerce-enhanced.js
|
709 |
+
/*
|
710 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
711 |
+
gtm4wp_woocommerce_addjs("
|
712 |
+
$( document ).on( 'click', '.mini_cart_item a.remove,.product-remove a.remove', function() {
|
713 |
+
var productdata = $( this );
|
714 |
+
|
715 |
+
var qty = 0;
|
716 |
+
var qty_element = $( this ).closest( '.cart_item' ).find( '.product-quantity input.qty' );
|
717 |
+
if ( 0 == qty_element.length ) {
|
718 |
+
qty_element = $( this ).closest( '.mini_cart_item' ).find( '.quantity' );
|
719 |
+
if ( qty_element.length > 0 ) {
|
720 |
+
qty = parseInt( qty_element.text() );
|
721 |
+
|
722 |
+
if ( isNaN( qty ) ) {
|
723 |
+
qty = 0;
|
724 |
+
}
|
725 |
+
}
|
726 |
+
} else {
|
727 |
+
qty = qty_element.val();
|
728 |
+
}
|
729 |
+
|
730 |
+
if ( 0 == qty ) {
|
731 |
+
return true;
|
732 |
+
}
|
733 |
+
|
734 |
+
". $gtm4wp_datalayer_name .".push({
|
735 |
+
'event': 'gtm4wp.removeFromCartEEC',
|
736 |
+
'ecommerce': {
|
737 |
+
'remove': {
|
738 |
+
'products': [{
|
739 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
740 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
741 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
742 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
743 |
+
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
744 |
+
'quantity': qty
|
745 |
+
}]
|
746 |
+
}
|
747 |
+
}
|
748 |
+
});
|
749 |
+
});
|
750 |
+
");
|
751 |
+
}
|
752 |
+
*/
|
753 |
+
|
754 |
+
if ( isset ( $_COOKIE[ "gtm4wp_product_readded_to_cart" ] ) ) {
|
755 |
+
$cart_item = $woo->cart->get_cart_item( $_COOKIE[ "gtm4wp_product_readded_to_cart" ] );
|
756 |
+
if ( !empty( $cart_item ) ) {
|
757 |
+
$product = $cart_item["data"];
|
758 |
+
|
759 |
+
$product_id = $product->get_id();
|
760 |
+
$product_type = $product->get_type();
|
761 |
+
|
762 |
+
if ( "variation" == $product_type ) {
|
763 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
764 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
765 |
+
} else {
|
766 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
767 |
+
}
|
768 |
+
|
769 |
+
$remarketing_id = $product_id;
|
770 |
+
$product_sku = $product->get_sku();
|
771 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
772 |
+
$remarketing_id = $product_sku;
|
773 |
+
}
|
774 |
+
|
775 |
+
$dataLayer["ecommerce"]["add"]["products"][] = array(
|
776 |
+
"name" => $product->get_title(),
|
777 |
+
"id" => $remarketing_id,
|
778 |
+
"price" => $product->get_price(),
|
779 |
+
"category" => $product_cat,
|
780 |
+
"stocklevel" => $product->get_stock_quantity(),
|
781 |
+
"quantity" => $cart_item["quantity"]
|
782 |
+
);
|
783 |
+
|
784 |
+
if ( "variation" == $product_type ) {
|
785 |
+
$dataLayer["ecommerce"]["add"][0][ "variant" ] = implode(",", $product->get_variation_attributes());
|
786 |
+
}
|
787 |
+
}
|
788 |
+
|
789 |
+
gtm4wp_woocommerce_addjs( "document.cookie = 'gtm4wp_product_readded_to_cart=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';" );
|
790 |
+
unset( $_COOKIE[ "gtm4wp_product_readded_to_cart" ] );
|
791 |
+
}
|
792 |
+
|
793 |
+
return $dataLayer;
|
794 |
+
}
|
795 |
+
|
796 |
+
function gtm4wp_woocommerce_single_add_to_cart_tracking() {
|
797 |
+
global $product, $gtm4wp_datalayer_name, $gtm4wp_options;
|
798 |
+
|
799 |
+
// exit early if there is nothing to do
|
800 |
+
if ( ( false === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) && ( false === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) {
|
801 |
+
return;
|
802 |
+
}
|
803 |
+
|
804 |
+
$product_id = $product->get_id();
|
805 |
+
|
806 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
807 |
+
|
808 |
+
$remarketing_id = $product_id;
|
809 |
+
$product_sku = $product->get_sku();
|
810 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
811 |
+
$remarketing_id = $product_sku;
|
812 |
+
}
|
813 |
+
|
814 |
+
$_temp_productdata = array(
|
815 |
+
"id" => $remarketing_id,
|
816 |
+
"name" => $product->get_title(),
|
817 |
+
"sku" => $product_sku ? $product_sku : $product_id,
|
818 |
+
"category" => $product_cat,
|
819 |
+
"price" => $product->get_price(),
|
820 |
+
"currency" => get_woocommerce_currency(),
|
821 |
+
"stocklevel" => $product->get_stock_quantity()
|
822 |
+
);
|
823 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "addtocartsingle" );
|
824 |
+
|
825 |
+
foreach( $eec_product_array as $eec_product_array_key => $eec_product_array_value ) {
|
826 |
+
echo '<input type="hidden" name="gtm4wp_' . esc_attr( $eec_product_array_key ). '" value="' . esc_attr( $eec_product_array_value ). '" />'."\n";
|
827 |
+
}
|
828 |
+
}
|
829 |
+
|
830 |
+
// moved to gtm4wp-woocommerce-enhanced.js
|
831 |
+
/*
|
832 |
+
function gtm4wp_woocommerce_wp_footer() {
|
833 |
+
global $gtm4wp_options, $gtm4wp_datalayer_name;
|
834 |
+
|
835 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
836 |
+
gtm4wp_woocommerce_addjs("
|
837 |
+
$( '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)' ).click(function() {
|
838 |
+
var productdata = $( this ).closest( '.product' ).find( '.gtm4wp_productdata' );
|
839 |
+
|
840 |
+
". $gtm4wp_datalayer_name .".push({
|
841 |
+
'event': 'gtm4wp.addProductToCart',
|
842 |
+
'productName': productdata.data( 'gtm4wp_product_name' ),
|
843 |
+
'productSKU': $( this ).data( 'product_sku' ),
|
844 |
+
'productID': $( this ).data( 'product_id' ),
|
845 |
+
});
|
846 |
+
});
|
847 |
+
");
|
848 |
+
}
|
849 |
+
|
850 |
+
if ( ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) && ( ! is_cart() ) && ( ! is_product() ) ) {
|
851 |
+
echo "
|
852 |
+
<script data-cfasync='false' type='text/javascript'>
|
853 |
+
(function($) {
|
854 |
+
if ( $( '.gtm4wp_productdata' ).length > 0 ) {
|
855 |
+
for( var i=0; i<". $gtm4wp_datalayer_name .".length; i++ ) {
|
856 |
+
if ( ". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ] ) {
|
857 |
+
break;
|
858 |
+
}
|
859 |
+
}
|
860 |
+
|
861 |
+
if ( i == ". $gtm4wp_datalayer_name .".length ) {
|
862 |
+
// no existing dyn remarketing data found in the datalayer
|
863 |
+
i = 0;
|
864 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ] = [];
|
865 |
+
}
|
866 |
+
|
867 |
+
if ( typeof ". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ].push == 'undefined' ) {
|
868 |
+
return false;
|
869 |
+
}
|
870 |
+
|
871 |
+
var productdata;
|
872 |
+
$( '.gtm4wp_productdata' ).each( function() {
|
873 |
+
productdata = jQuery( this );
|
874 |
+
|
875 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecomm_prodid' ].push( '".gtm4wp_prefix_productid("")."' + productdata.data( 'gtm4wp_product_id' ) );
|
876 |
+
});
|
877 |
+
}
|
878 |
+
})(jQuery);
|
879 |
+
</script>";
|
880 |
+
}
|
881 |
+
|
882 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
883 |
+
echo "
|
884 |
+
<script data-cfasync='false' type='text/javascript'>
|
885 |
+
(function($) {
|
886 |
+
if ( $( '.gtm4wp_productdata,.widget-product-item' ).length > 0 ) {
|
887 |
+
for( var i=0; i<". $gtm4wp_datalayer_name .".length; i++ ) {
|
888 |
+
if ( ". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ] ) {
|
889 |
+
|
890 |
+
if ( ! ". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ][ 'impressions' ] ) {
|
891 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ][ 'impressions' ] = [];
|
892 |
+
}
|
893 |
+
|
894 |
+
break;
|
895 |
+
}
|
896 |
+
}
|
897 |
+
|
898 |
+
if ( i == ". $gtm4wp_datalayer_name .".length ) {
|
899 |
+
// no existing ecommerce data found in the datalayer
|
900 |
+
i = 0;
|
901 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ] = {};
|
902 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ][ 'impressions' ] = [];
|
903 |
+
}
|
904 |
+
|
905 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ][ 'currencyCode' ] = '".get_woocommerce_currency()."';
|
906 |
+
|
907 |
+
var productdata;
|
908 |
+
$( '.gtm4wp_productdata,.widget-product-item' ).each( function() {
|
909 |
+
productdata = jQuery( this );
|
910 |
+
|
911 |
+
". $gtm4wp_datalayer_name ."[ i ][ 'ecommerce' ][ 'impressions' ].push({
|
912 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
913 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
914 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
915 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
916 |
+
'position': productdata.data( 'gtm4wp_product_listposition' ),
|
917 |
+
'list': productdata.data( 'gtm4wp_productlist_name' )
|
918 |
+
});
|
919 |
+
});
|
920 |
+
}
|
921 |
+
})(jQuery);
|
922 |
+
</script>";
|
923 |
+
|
924 |
+
gtm4wp_woocommerce_addjs("
|
925 |
+
$( '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)' ).click(function() {
|
926 |
+
var productdata = $( this ).closest( '.product' ).find( '.gtm4wp_productdata' );
|
927 |
+
|
928 |
+
". $gtm4wp_datalayer_name .".push({
|
929 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
930 |
+
'ecommerce': {
|
931 |
+
'currencyCode': '".get_woocommerce_currency()."',
|
932 |
+
'add': {
|
933 |
+
'products': [{
|
934 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
935 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
936 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
937 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
938 |
+
'quantity': 1
|
939 |
+
}]
|
940 |
+
}
|
941 |
+
}
|
942 |
+
});
|
943 |
+
});
|
944 |
+
");
|
945 |
+
}
|
946 |
+
}
|
947 |
+
*/
|
948 |
+
|
949 |
+
// moved to gtm4wp-woocommerce-enhanced.js
|
950 |
+
/*
|
951 |
+
function gtm4wp_woocommerce_enhanced_ecom_product_click() {
|
952 |
+
global $gtm4wp_datalayer_name;
|
953 |
+
|
954 |
+
gtm4wp_woocommerce_addjs("
|
955 |
+
$( '.products li:not(.product-category) a:not(.add_to_cart_button),.widget-product-item' ).click(function( event ) {
|
956 |
+
if ( 'undefined' == typeof google_tag_manager ) {
|
957 |
+
return true;
|
958 |
+
}
|
959 |
+
|
960 |
+
var _productdata = $( this ).closest( '.product' );
|
961 |
+
|
962 |
+
if ( _productdata.length > 0 ) {
|
963 |
+
var productdata = _productdata.find( '.gtm4wp_productdata' );
|
964 |
+
|
965 |
+
} else {
|
966 |
+
var _productdata = $( this ).closest( 'ul.products li' );
|
967 |
+
|
968 |
+
if ( _productdata.length > 0 ) {
|
969 |
+
var productdata = _productdata.find( '.gtm4wp_productdata' );
|
970 |
+
|
971 |
+
} else {
|
972 |
+
var productdata = jQuery( this );
|
973 |
+
|
974 |
+
}
|
975 |
+
}
|
976 |
+
|
977 |
+
if ( ( 'undefined' == typeof productdata.data( 'gtm4wp_product_id' ) ) || ( '' == productdata.data( 'gtm4wp_product_id' ) ) ) {
|
978 |
+
return true;
|
979 |
+
}
|
980 |
+
|
981 |
+
// only act on links pointing to the product detail page
|
982 |
+
if ( productdata.data( 'gtm4wp_product_url' ) != $( this ).attr( 'href' ) ) {
|
983 |
+
return true;
|
984 |
+
}
|
985 |
+
|
986 |
+
var ctrl_key_pressed = event.ctrlKey;
|
987 |
+
|
988 |
+
event.preventDefault();
|
989 |
+
if ( ctrl_key_pressed ) {
|
990 |
+
// we need to open the new tab/page here so that popup blocker of the browser doesn't block our code
|
991 |
+
var _productpage = window.open( 'about:blank', '_blank' );
|
992 |
+
}
|
993 |
+
|
994 |
+
". $gtm4wp_datalayer_name .".push({
|
995 |
+
'event': 'gtm4wp.productClickEEC',
|
996 |
+
'ecommerce': {
|
997 |
+
'currencyCode': '".get_woocommerce_currency()."',
|
998 |
+
'click': {
|
999 |
+
'actionField': {'list': productdata.data( 'gtm4wp_productlist_name' )},
|
1000 |
+
'products': [{
|
1001 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
1002 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
1003 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
1004 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
1005 |
+
'position': productdata.data( 'gtm4wp_product_listposition' )
|
1006 |
+
}]
|
1007 |
+
}
|
1008 |
+
},
|
1009 |
+
'eventCallback': function() {
|
1010 |
+
if ( ctrl_key_pressed && _productpage ) {
|
1011 |
+
_productpage.location.href= productdata.data( 'gtm4wp_product_url' );
|
1012 |
+
} else {
|
1013 |
+
document.location.href = productdata.data( 'gtm4wp_product_url' )
|
1014 |
+
}
|
1015 |
+
},
|
1016 |
+
'eventTimeout': 2000
|
1017 |
+
});
|
1018 |
+
});
|
1019 |
+
");
|
1020 |
+
}
|
1021 |
+
*/
|
1022 |
+
|
1023 |
+
$GLOBALS["gtm4wp_cart_item_proddata"] = '';
|
1024 |
+
function gtm4wp_woocommerce_cart_item_product_filter( $product, $cart_item="", $cart_id="" ) {
|
1025 |
+
global $gtm4wp_options, $gtm4wp_is_woocommerce3;
|
1026 |
+
|
1027 |
+
$product_id = $product->get_id();
|
1028 |
+
$product_type = $product->get_type();
|
1029 |
+
|
1030 |
+
if ( "variation" == $product_type ) {
|
1031 |
+
$parent_product_id = ( $gtm4wp_is_woocommerce3 ? $product->get_parent_id() : $product->id);
|
1032 |
+
$product_cat = gtm4wp_get_product_category( $parent_product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
1033 |
+
} else {
|
1034 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
$remarketing_id = $product_id;
|
1038 |
+
$product_sku = $product->get_sku();
|
1039 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
1040 |
+
$remarketing_id = $product_sku;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
$_temp_productdata = array(
|
1044 |
+
"id" => $remarketing_id,
|
1045 |
+
"name" => $product->get_title(),
|
1046 |
+
"price" => $product->get_price(),
|
1047 |
+
"category" => $product_cat,
|
1048 |
+
"productlink" => apply_filters( 'the_permalink', get_permalink(), 0),
|
1049 |
+
"variant" => "",
|
1050 |
+
"stocklevel" => $product->get_stock_quantity()
|
1051 |
+
);
|
1052 |
+
|
1053 |
+
if ( "variation" == $product_type ) {
|
1054 |
+
$_temp_productdata[ "variant" ] = implode(",", $product->get_variation_attributes());
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "cart" );
|
1058 |
+
$GLOBALS["gtm4wp_cart_item_proddata"] = $eec_product_array;
|
1059 |
+
|
1060 |
+
return $product;
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
function gtm4wp_woocommerce_cart_item_remove_link_filter( $remove_from_cart_link ) {
|
1064 |
+
if ( ! isset( $GLOBALS["gtm4wp_cart_item_proddata"] ) ) {
|
1065 |
+
return $remove_from_cart_link;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
if ( ! is_array( $GLOBALS["gtm4wp_cart_item_proddata"] ) ) {
|
1069 |
+
return $remove_from_cart_link;
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
$cartlink_with_data = sprintf('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" href="',
|
1073 |
+
esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["id"] ),
|
1074 |
+
esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["name"] ),
|
1075 |
+
esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["price"] ),
|
1076 |
+
esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["category"] ),
|
1077 |
+
esc_url( $GLOBALS["gtm4wp_cart_item_proddata"]["productlink"] ),
|
1078 |
+
esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["variant"] ),
|
1079 |
+
esc_attr( $GLOBALS["gtm4wp_cart_item_proddata"]["stocklevel"] )
|
1080 |
+
);
|
1081 |
+
$GLOBALS["gtm4wp_cart_item_proddata"] = '';
|
1082 |
+
|
1083 |
+
return gtm4wp_str_replace_first( 'href="', $cartlink_with_data, $remove_from_cart_link );
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
function gtp4wp_woocommerce_reset_loop() {
|
1087 |
+
global $woocommerce_loop;
|
1088 |
+
|
1089 |
+
$woocommerce_loop[ "listtype" ] = "";
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
function gtm4wp_woocommerce_add_related_to_loop( $arg ) {
|
1093 |
+
global $woocommerce_loop;
|
1094 |
+
|
1095 |
+
$woocommerce_loop[ "listtype" ] = __( "Related Products", "duracelltomi-google-tag-manager" );
|
1096 |
+
|
1097 |
+
return $arg;
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
function gtm4wp_woocommerce_add_cross_sell_to_loop( $arg ) {
|
1101 |
+
global $woocommerce_loop;
|
1102 |
+
|
1103 |
+
$woocommerce_loop[ "listtype" ] = __( "Cross-Sell Products", "duracelltomi-google-tag-manager" );
|
1104 |
+
|
1105 |
+
return $arg;
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
function gtm4wp_woocommerce_add_upsells_to_loop( $arg ) {
|
1109 |
+
global $woocommerce_loop;
|
1110 |
+
|
1111 |
+
$woocommerce_loop[ "listtype" ] = __( "Upsell Products", "duracelltomi-google-tag-manager" );
|
1112 |
+
|
1113 |
+
return $arg;
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
function gtm4wp_woocommerce_before_template_part( $template_name ) {
|
1117 |
+
ob_start();
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
function gtm4wp_woocommerce_after_template_part( $template_name ) {
|
1121 |
+
global $product, $gtm4wp_product_counter, $gtm4wp_last_widget_title, $gtm4wp_options;
|
1122 |
+
|
1123 |
+
$productitem = ob_get_contents();
|
1124 |
+
ob_end_clean();
|
1125 |
+
|
1126 |
+
if ( "content-widget-product.php" == $template_name ) {
|
1127 |
+
$product_id = $product->get_id();
|
1128 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
1129 |
+
|
1130 |
+
$remarketing_id = $product_id;
|
1131 |
+
$product_sku = $product->get_sku();
|
1132 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
1133 |
+
$remarketing_id = $product_sku;
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
$_temp_productdata = array(
|
1137 |
+
"id" => $remarketing_id,
|
1138 |
+
"name" => $product->get_title(),
|
1139 |
+
"price" => $product->get_price(),
|
1140 |
+
"category" => $product_cat,
|
1141 |
+
"productlink" => apply_filters( 'the_permalink', get_permalink(), 0),
|
1142 |
+
"listname" => $gtm4wp_last_widget_title,
|
1143 |
+
"listposition" => $gtm4wp_product_counter,
|
1144 |
+
"stocklevel" => $product->get_stock_quantity()
|
1145 |
+
);
|
1146 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "widgetproduct" );
|
1147 |
+
|
1148 |
+
$productlink_with_data = sprintf('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" href="',
|
1149 |
+
esc_attr( $eec_product_array[ "id" ] ),
|
1150 |
+
esc_attr( $eec_product_array[ "name" ] ),
|
1151 |
+
esc_attr( $eec_product_array[ "price" ] ),
|
1152 |
+
esc_attr( $eec_product_array[ "category" ] ),
|
1153 |
+
esc_url( $eec_product_array[ "productlink" ] ),
|
1154 |
+
esc_attr( $eec_product_array[ "listname" ] ),
|
1155 |
+
esc_attr( $eec_product_array[ "listposition" ] ),
|
1156 |
+
esc_attr( $eec_product_array[ "stocklevel" ] )
|
1157 |
+
);
|
1158 |
+
|
1159 |
+
$gtm4wp_product_counter++;
|
1160 |
+
|
1161 |
+
$productitem = str_replace( 'href="', $productlink_with_data, $productitem );
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
echo $productitem;
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
function gtm4wp_widget_title_filter( $widget_title ) {
|
1168 |
+
global $gtm4wp_product_counter, $gtm4wp_last_widget_title;
|
1169 |
+
|
1170 |
+
$gtm4wp_product_counter = 1;
|
1171 |
+
$gtm4wp_last_widget_title = $widget_title . __( " (widget)", "duracelltomi-google-tag-manager" );
|
1172 |
+
|
1173 |
+
return $widget_title;
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
function gtm4wp_before_recent_products_loop() {
|
1177 |
+
global $woocommerce_loop;
|
1178 |
+
|
1179 |
+
$woocommerce_loop[ "listtype" ] = __( "Recent Products", "duracelltomi-google-tag-manager" );
|
1180 |
+
}
|
1181 |
+
|
1182 |
+
function gtm4wp_before_sale_products_loop() {
|
1183 |
+
global $woocommerce_loop;
|
1184 |
+
|
1185 |
+
$woocommerce_loop[ "listtype" ] = __( "Sale Products", "duracelltomi-google-tag-manager" );
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
function gtm4wp_before_best_selling_products_loop() {
|
1189 |
+
global $woocommerce_loop;
|
1190 |
+
|
1191 |
+
$woocommerce_loop[ "listtype" ] = __( "Best Selling Products", "duracelltomi-google-tag-manager" );
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
function gtm4wp_before_top_rated_products_loop() {
|
1195 |
+
global $woocommerce_loop;
|
1196 |
+
|
1197 |
+
$woocommerce_loop[ "listtype" ] = __( "Top Rated Products", "duracelltomi-google-tag-manager" );
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
function gtm4wp_before_featured_products_loop() {
|
1201 |
+
global $woocommerce_loop;
|
1202 |
+
|
1203 |
+
$woocommerce_loop[ "listtype" ] = __( "Featured Products", "duracelltomi-google-tag-manager" );
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
function gtm4wp_before_related_products_loop() {
|
1207 |
+
global $woocommerce_loop;
|
1208 |
+
|
1209 |
+
$woocommerce_loop[ "listtype" ] = __( "Related Products", "duracelltomi-google-tag-manager" );
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
function gtm4wp_woocommerce_before_shop_loop_item() {
|
1213 |
+
global $product, $woocommerce_loop, $wp_query, $gtm4wp_options;
|
1214 |
+
|
1215 |
+
if ( !isset( $product ) ) {
|
1216 |
+
return;
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
$product_id = $product->get_id();
|
1220 |
+
|
1221 |
+
$product_cat = "";
|
1222 |
+
if ( is_product_category() ) {
|
1223 |
+
global $wp_query;
|
1224 |
+
$cat_obj = $wp_query->get_queried_object();
|
1225 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] ) {
|
1226 |
+
$product_cat = gtm4wp_get_product_category_hierarchy( $cat_obj->term_id );
|
1227 |
+
} else {
|
1228 |
+
$product_cat = $cat_obj->name;
|
1229 |
+
}
|
1230 |
+
} else {
|
1231 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
if ( is_search() ) {
|
1235 |
+
$list_name = __( "Search Results", "duracelltomi-google-tag-manager" );
|
1236 |
+
} else if ( isset( $woocommerce_loop[ "listtype" ] ) && ( $woocommerce_loop[ "listtype" ] != '' ) ) {
|
1237 |
+
$list_name = $woocommerce_loop[ "listtype" ];
|
1238 |
+
} else {
|
1239 |
+
$list_name = __( "General Product List", "duracelltomi-google-tag-manager" );
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
|
1243 |
+
$posts_per_page = get_query_var('posts_per_page');
|
1244 |
+
if ( $posts_per_page < 1 ) {
|
1245 |
+
$posts_per_page = 1;
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
$remarketing_id = $product_id;
|
1249 |
+
$product_sku = $product->get_sku();
|
1250 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] && ( "" != $product_sku ) ) {
|
1251 |
+
$remarketing_id = $product_sku;
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
$_temp_productdata = array(
|
1255 |
+
"id" => $remarketing_id,
|
1256 |
+
"name" => $product->get_title(),
|
1257 |
+
"price" => $product->get_price(),
|
1258 |
+
"category" => $product_cat,
|
1259 |
+
"productlink" => apply_filters( 'the_permalink', get_permalink(), 0),
|
1260 |
+
"listname" => $list_name,
|
1261 |
+
"listposition" => $woocommerce_loop[ "loop" ] + ( $posts_per_page * ($paged-1) ),
|
1262 |
+
"stocklevel" => $product->get_stock_quantity()
|
1263 |
+
);
|
1264 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "productlist" );
|
1265 |
+
|
1266 |
+
printf('<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"></span>',
|
1267 |
+
esc_attr( $eec_product_array[ "id" ] ),
|
1268 |
+
esc_attr( $eec_product_array[ "name" ] ),
|
1269 |
+
esc_attr( $eec_product_array[ "price" ] ),
|
1270 |
+
esc_attr( $eec_product_array[ "category" ] ),
|
1271 |
+
esc_url( $eec_product_array[ "productlink" ] ),
|
1272 |
+
esc_attr( $eec_product_array[ "listposition" ] ),
|
1273 |
+
esc_attr( $eec_product_array[ "listname" ] ),
|
1274 |
+
esc_attr( $eec_product_array[ "stocklevel" ] )
|
1275 |
+
);
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
function gtm4wp_woocommerce_cart_item_restored( $cart_item_key ) {
|
1279 |
+
setcookie( "gtm4wp_product_readded_to_cart", $cart_item_key );
|
1280 |
+
}
|
1281 |
+
|
1282 |
+
function gtm4wp_woocommerce_enqueue_scripts() {
|
1283 |
+
global $gtm4wp_options, $gtp4wp_plugin_url;
|
1284 |
+
|
1285 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
|
1286 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC, false);
|
1287 |
+
wp_enqueue_script( "gtm4wp-woocommerce-classic", $gtp4wp_plugin_url . "js/gtm4wp-woocommerce-classic.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1291 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC, false);
|
1292 |
+
wp_enqueue_script( "gtm4wp-woocommerce-enhanced", $gtp4wp_plugin_url . "js/gtm4wp-woocommerce-enhanced.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
1293 |
+
}
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
function gtm4wp_wc_quick_view_before_single_product() {
|
1297 |
+
global $gtm4wp_options, $gtm4wp_datalayer_name;
|
1298 |
+
|
1299 |
+
$dataLayer = array(
|
1300 |
+
"event" => "gtm4wp.changeDetailViewEEC"
|
1301 |
+
);
|
1302 |
+
|
1303 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) || ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) ) {
|
1304 |
+
$postid = get_the_ID();
|
1305 |
+
$product = wc_get_product( $postid );
|
1306 |
+
$product_id = $product->get_id();
|
1307 |
+
|
1308 |
+
$product_cat = gtm4wp_get_product_category( $product_id, $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH ] );
|
1309 |
+
|
1310 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ] ) {
|
1311 |
+
$product_sku = $product->get_sku();
|
1312 |
+
if ( "" != $product_sku ) {
|
1313 |
+
$product_id = $product_sku;
|
1314 |
+
}
|
1315 |
+
}
|
1316 |
+
$remarketing_id = (string)$product_id;
|
1317 |
+
$product_price = $product->get_price();
|
1318 |
+
|
1319 |
+
if ( "variable" != $product->get_type() ) {
|
1320 |
+
$_temp_productdata = array(
|
1321 |
+
"name" => gtm4wp_woocommerce_html_entity_decode( get_the_title() ),
|
1322 |
+
"id" => $product_id,
|
1323 |
+
"price" => $product_price,
|
1324 |
+
"category" => $product_cat,
|
1325 |
+
"stocklevel" => $product->get_stock_quantity()
|
1326 |
+
);
|
1327 |
+
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "productdetail" );
|
1328 |
+
|
1329 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ] ) {
|
1330 |
+
$dataLayer["ecomm_prodid"] = gtm4wp_prefix_productid( $remarketing_id );
|
1331 |
+
$dataLayer["ecomm_pagetype"] = "product";
|
1332 |
+
$dataLayer["ecomm_totalvalue"] = (float)$eec_product_array[ "price" ];
|
1333 |
+
}
|
1334 |
+
|
1335 |
+
if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1336 |
+
$dataLayer["ecommerce"] = array(
|
1337 |
+
"detail" => array(
|
1338 |
+
"products" => array($eec_product_array)
|
1339 |
+
)
|
1340 |
+
);
|
1341 |
+
}
|
1342 |
+
} else {
|
1343 |
+
$dataLayer["ecomm_prodid"] = gtm4wp_prefix_productid( $remarketing_id );
|
1344 |
+
$dataLayer["ecomm_pagetype"] = "product";
|
1345 |
+
$dataLayer["ecomm_totalvalue"] = $product_price;
|
1346 |
+
}
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
echo '
|
1350 |
+
<script>
|
1351 |
+
'. $gtm4wp_datalayer_name .'.push(' . json_encode( $dataLayer ). ');
|
1352 |
+
</script>';
|
1353 |
+
}
|
1354 |
+
|
1355 |
+
// do not add filter if someone enabled WooCommerce integration without an activated WooCommerce plugin
|
1356 |
+
if ( function_exists ( "WC" ) ) {
|
1357 |
+
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtm4wp_woocommerce_datalayer_filter_items" );
|
1358 |
+
|
1359 |
+
add_filter( "loop_end", "gtp4wp_woocommerce_reset_loop" );
|
1360 |
+
add_action( "woocommerce_before_shop_loop_item", "gtm4wp_woocommerce_before_shop_loop_item" );
|
1361 |
+
add_action( "woocommerce_after_add_to_cart_button", "gtm4wp_woocommerce_single_add_to_cart_tracking" );
|
1362 |
+
|
1363 |
+
// add_action( "wp_footer", "gtm4wp_woocommerce_wp_footer" );
|
1364 |
+
add_action( "wp_enqueue_scripts", "gtm4wp_woocommerce_enqueue_scripts" );
|
1365 |
+
add_filter( GTM4WP_WPACTION_ADDGLOBALVARS, "gtm4wp_woocommerce_addglobalvars" );
|
1366 |
+
|
1367 |
+
if ( true === $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1368 |
+
// add_action( "wp_footer", "gtm4wp_woocommerce_enhanced_ecom_product_click" );
|
1369 |
+
add_action( "woocommerce_before_template_part", "gtm4wp_woocommerce_before_template_part" );
|
1370 |
+
add_action( "woocommerce_after_template_part", "gtm4wp_woocommerce_after_template_part" );
|
1371 |
+
add_filter( "widget_title", "gtm4wp_widget_title_filter" );
|
1372 |
+
add_action( "wc_quick_view_before_single_product", "gtm4wp_wc_quick_view_before_single_product" );
|
1373 |
+
|
1374 |
+
add_filter( "woocommerce_cart_item_product", "gtm4wp_woocommerce_cart_item_product_filter" );
|
1375 |
+
add_filter( "woocommerce_cart_item_remove_link", "gtm4wp_woocommerce_cart_item_remove_link_filter" );
|
1376 |
+
add_action( "woocommerce_cart_item_restored", "gtm4wp_woocommerce_cart_item_restored" );
|
1377 |
+
|
1378 |
+
add_filter( "woocommerce_related_products_args", "gtm4wp_woocommerce_add_related_to_loop" );
|
1379 |
+
add_filter( "woocommerce_related_products_columns", "gtm4wp_woocommerce_add_related_to_loop" );
|
1380 |
+
add_filter( "woocommerce_cross_sells_columns", "gtm4wp_woocommerce_add_cross_sell_to_loop" );
|
1381 |
+
add_filter( "woocommerce_upsells_columns", "gtm4wp_woocommerce_add_upsells_to_loop" );
|
1382 |
+
|
1383 |
+
add_action( "woocommerce_shortcode_before_recent_products_loop", "gtm4wp_before_recent_products_loop" );
|
1384 |
+
add_action( "woocommerce_shortcode_before_sale_products_loop", "gtm4wp_before_sale_products_loop" );
|
1385 |
+
add_action( "woocommerce_shortcode_before_best_selling_products_loop", "gtm4wp_before_best_selling_products_loop" );
|
1386 |
+
add_action( "woocommerce_shortcode_before_top_rated_products_loop", "gtm4wp_before_top_rated_products_loop" );
|
1387 |
+
add_action( "woocommerce_shortcode_before_featured_products_loop", "gtm4wp_before_featured_products_loop" );
|
1388 |
+
add_action( "woocommerce_shortcode_before_related_products_loop", "gtm4wp_before_related_products_loop" );
|
1389 |
+
}
|
1390 |
+
}
|
integration/youtube.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
function gtm4wp_youtube( $return, $url, $data ) {
|
3 |
-
|
4 |
-
|
5 |
-
} else {
|
6 |
-
|
7 |
-
}
|
8 |
-
}
|
9 |
-
|
10 |
-
add_filter( "oembed_result", "gtm4wp_youtube", 10, 3 );
|
11 |
-
|
12 |
-
if ( ! is_admin() ) {
|
13 |
-
$in_footer = apply_filters( 'gtm4wp_youtube', false);
|
14 |
-
wp_enqueue_script( "gtm4wp-youtube", $gtp4wp_plugin_url . "js/gtm4wp-youtube.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
15 |
-
}
|
1 |
+
<?php
|
2 |
+
function gtm4wp_youtube( $return, $url, $data ) {
|
3 |
+
if ( false !== strpos( $return, "youtube.com" ) ) {
|
4 |
+
return str_replace( "feature=oembed", "feature=oembed&enablejsapi=1&origin=" . site_url(), $return );
|
5 |
+
} else {
|
6 |
+
return $return;
|
7 |
+
}
|
8 |
+
}
|
9 |
+
|
10 |
+
add_filter( "oembed_result", "gtm4wp_youtube", 10, 3 );
|
11 |
+
|
12 |
+
if ( ! is_admin() ) {
|
13 |
+
$in_footer = apply_filters( 'gtm4wp_youtube', false);
|
14 |
+
wp_enqueue_script( "gtm4wp-youtube", $gtp4wp_plugin_url . "js/gtm4wp-youtube.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
15 |
+
}
|
js/admin-subtabs.js
CHANGED
@@ -1,77 +1,81 @@
|
|
1 |
-
|
2 |
-
var adminsubtabs = {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
var adminsubtabs = {
|
3 |
+
0: {},
|
4 |
+
1: {
|
5 |
+
"posts": {
|
6 |
+
tabtext: gtm4wp.posttabtitle,
|
7 |
+
numitems: 10
|
8 |
+
},
|
9 |
+
"search": {
|
10 |
+
tabtext: gtm4wp.searchtabtitle,
|
11 |
+
numitems: 1
|
12 |
+
},
|
13 |
+
"visitor": {
|
14 |
+
tabtext: gtm4wp.visitortabtitle,
|
15 |
+
numitems: 7
|
16 |
+
},
|
17 |
+
"adwords": {
|
18 |
+
tabtext: gtm4wp.adwordstabtitle,
|
19 |
+
numitems: 1
|
20 |
+
},
|
21 |
+
"whichbrowser": {
|
22 |
+
tabtext: gtm4wp.browsertabtitle,
|
23 |
+
numitems: 3
|
24 |
+
},
|
25 |
+
"weather": {
|
26 |
+
tabtext: gtm4wp.weathertabtitle,
|
27 |
+
numitems: 5
|
28 |
+
},
|
29 |
+
"site": {
|
30 |
+
tabtext: gtm4wp.sitetabtitle,
|
31 |
+
numitems: 2
|
32 |
+
}/*,
|
33 |
+
"misc": {
|
34 |
+
tabtext: gtm4wp.misctabtitle,
|
35 |
+
numitems: 1
|
36 |
+
}*/
|
37 |
+
},
|
38 |
+
2: {
|
39 |
+
"generalevents": {
|
40 |
+
tabtext: gtm4wp.generaleventstabtitle,
|
41 |
+
numitems: 3
|
42 |
+
},
|
43 |
+
"mediaevents": {
|
44 |
+
tabtext: gtm4wp.mediaeventstabtitle,
|
45 |
+
numitems: 3
|
46 |
+
},
|
47 |
+
"depecratedevents": {
|
48 |
+
tabtext: gtm4wp.depecratedeventstabtitle,
|
49 |
+
numitems: 4
|
50 |
+
}
|
51 |
+
},
|
52 |
+
3: {},
|
53 |
+
4: {
|
54 |
+
"blocktags": {
|
55 |
+
tabtext: gtm4wp.blocktagstabtitle,
|
56 |
+
numitems: 20
|
57 |
+
},
|
58 |
+
"blockmacros": {
|
59 |
+
tabtext: gtm4wp.blockmacrostabtitle,
|
60 |
+
numitems: 20
|
61 |
+
}
|
62 |
+
},
|
63 |
+
5: {
|
64 |
+
"int-wpcf7": {
|
65 |
+
tabtext: gtm4wp.wpcf7tabtitle,
|
66 |
+
numitems: 1
|
67 |
+
},
|
68 |
+
"int-wc": {
|
69 |
+
tabtext: gtm4wp.wctabtitle,
|
70 |
+
numitems: 11
|
71 |
+
},
|
72 |
+
"int-google-optimize": {
|
73 |
+
tabtext: gtm4wp.gotabtitle,
|
74 |
+
numitems: 3
|
75 |
+
},
|
76 |
+
"int-amp": {
|
77 |
+
tabtext: gtm4wp.amptabtitle,
|
78 |
+
numitems: 1
|
79 |
+
}
|
80 |
+
}
|
81 |
+
};
|
js/admin-tabcreator.js
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
|
2 |
-
var admintabs = [];
|
3 |
-
var adminsubtabsdata = window
|
4 |
-
var adminsubtabs = [];
|
5 |
-
|
6 |
-
jQuery( '#wpbody form h2' ).each(function( i ) {
|
7 |
-
admintabs.push( '<a class="nav-tab" href="#">' + jQuery(this).text() + '</a>' );
|
8 |
-
|
9 |
-
jQuery(this)
|
10 |
-
.remove();
|
11 |
-
|
12 |
-
if ( adminsubtabsdata[ i ] ) {
|
13 |
-
var _subtabs = [];
|
14 |
-
var _startrow = 0;
|
15 |
-
|
16 |
-
for ( 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 |
-
}
|
24 |
-
}
|
25 |
-
});
|
26 |
-
|
27 |
-
jQuery("#wpbody form[action='options.php']")
|
28 |
-
.prepend( adminsubtabs.join('') )
|
29 |
-
.prepend( '<h2 class="nav-tab-wrapper">' + admintabs.join('') + '</h2>' );
|
30 |
-
|
31 |
-
jQuery( '.adminsubtabs li a' )
|
32 |
-
.on( 'click', function() {
|
33 |
-
var jqthis = jQuery(this);
|
34 |
-
|
35 |
-
jqthis
|
36 |
-
.parent()
|
37 |
-
.parent()
|
38 |
-
.find( 'a' )
|
39 |
-
.removeClass( 'subtab-active' );
|
40 |
-
|
41 |
-
jqthis
|
42 |
-
.addClass( 'subtab-active' );
|
43 |
-
|
44 |
-
jQuery( '.form-table:eq(' + jqthis.data( 'formtableid' ) + ') tr' )
|
45 |
-
.hide()
|
46 |
-
.slice( jqthis.data('startrow'), jqthis.data('endrow') )
|
47 |
-
.show();
|
48 |
-
|
49 |
-
return false;
|
50 |
-
});
|
51 |
-
|
52 |
-
jQuery( '.nav-tab-wrapper a' )
|
53 |
-
.on( "click", function() {
|
54 |
-
jQuery( '.nav-tab-wrapper a.nav-tab-active' )
|
55 |
-
.removeClass( "nav-tab-active" );
|
56 |
-
|
57 |
-
jQuery( '#wpbody form .tabinfo,#wpbody form .form-table,.adminsubtabs' )
|
58 |
-
.hide();
|
59 |
-
|
60 |
-
var tabindex = jQuery(this)
|
61 |
-
.addClass( 'nav-tab-active' )
|
62 |
-
.index();
|
63 |
-
|
64 |
-
jQuery( '#wpbody form .tabinfo:eq(' + tabindex + '),#wpbody form .form-table:eq(' + tabindex + ')' )
|
65 |
-
.show();
|
66 |
-
|
67 |
-
jQuery( '#wpbody #adminsubtabs' + tabindex + ':not(.subtab-activated)' )
|
68 |
-
.find( 'a:first' )
|
69 |
-
.trigger( 'click' );
|
70 |
-
|
71 |
-
jQuery( '#wpbody #adminsubtabs' + tabindex )
|
72 |
-
.addClass( 'subtab-activated' )
|
73 |
-
.show();
|
74 |
-
|
75 |
-
return false;
|
76 |
-
});
|
77 |
-
|
78 |
-
jQuery( '.nav-tab-wrapper a:first' )
|
79 |
-
.trigger( 'click' );
|
80 |
-
});
|
1 |
+
jQuery( function() {
|
2 |
+
var admintabs = [];
|
3 |
+
var adminsubtabsdata = window.adminsubtabs || {};
|
4 |
+
var adminsubtabs = [];
|
5 |
+
|
6 |
+
jQuery( '#wpbody form h2' ).each(function( i ) {
|
7 |
+
admintabs.push( '<a class="nav-tab" href="#">' + jQuery(this).text() + '</a>' );
|
8 |
+
|
9 |
+
jQuery(this)
|
10 |
+
.remove();
|
11 |
+
|
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 |
+
}
|
24 |
+
}
|
25 |
+
});
|
26 |
+
|
27 |
+
jQuery("#wpbody form[action='options.php']")
|
28 |
+
.prepend( adminsubtabs.join('') )
|
29 |
+
.prepend( '<h2 class="nav-tab-wrapper">' + admintabs.join('') + '</h2>' );
|
30 |
+
|
31 |
+
jQuery( '.adminsubtabs li a' )
|
32 |
+
.on( 'click', function() {
|
33 |
+
var jqthis = jQuery(this);
|
34 |
+
|
35 |
+
jqthis
|
36 |
+
.parent()
|
37 |
+
.parent()
|
38 |
+
.find( 'a' )
|
39 |
+
.removeClass( 'subtab-active' );
|
40 |
+
|
41 |
+
jqthis
|
42 |
+
.addClass( 'subtab-active' );
|
43 |
+
|
44 |
+
jQuery( '.form-table:eq(' + jqthis.data( 'formtableid' ) + ') tr' )
|
45 |
+
.hide()
|
46 |
+
.slice( jqthis.data('startrow'), jqthis.data('endrow') )
|
47 |
+
.show();
|
48 |
+
|
49 |
+
return false;
|
50 |
+
});
|
51 |
+
|
52 |
+
jQuery( '.nav-tab-wrapper a' )
|
53 |
+
.on( "click", function() {
|
54 |
+
jQuery( '.nav-tab-wrapper a.nav-tab-active' )
|
55 |
+
.removeClass( "nav-tab-active" );
|
56 |
+
|
57 |
+
jQuery( '#wpbody form .tabinfo,#wpbody form .form-table,.adminsubtabs' )
|
58 |
+
.hide();
|
59 |
+
|
60 |
+
var tabindex = jQuery(this)
|
61 |
+
.addClass( 'nav-tab-active' )
|
62 |
+
.index();
|
63 |
+
|
64 |
+
jQuery( '#wpbody form .tabinfo:eq(' + tabindex + '),#wpbody form .form-table:eq(' + tabindex + ')' )
|
65 |
+
.show();
|
66 |
+
|
67 |
+
jQuery( '#wpbody #adminsubtabs' + tabindex + ':not(.subtab-activated)' )
|
68 |
+
.find( 'a:first' )
|
69 |
+
.trigger( 'click' );
|
70 |
+
|
71 |
+
jQuery( '#wpbody #adminsubtabs' + tabindex )
|
72 |
+
.addClass( 'subtab-activated' )
|
73 |
+
.show();
|
74 |
+
|
75 |
+
return false;
|
76 |
+
});
|
77 |
+
|
78 |
+
jQuery( '.nav-tab-wrapper a:first' )
|
79 |
+
.trigger( 'click' );
|
80 |
+
});
|
js/analytics-talk-content-tracking.js
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
/*
|
2 |
-
* Source: http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
|
3 |
-
* Original authors:
|
4 |
-
* - Nick Mihailovski
|
5 |
-
* - Thomas Baekdal
|
6 |
-
* - Avinash Kaushik
|
7 |
-
* - Joost de Valk
|
8 |
-
* - Eivind Savio
|
9 |
-
* - Justin Cutroni
|
10 |
-
*
|
11 |
-
* Google Tag Manager dataLayer events added by:
|
12 |
-
* Thomas Geiger
|
13 |
-
* gtm4wp.com
|
14 |
-
*/
|
15 |
-
|
16 |
-
if ( "undefined" == typeof console ) {
|
17 |
-
window.console = {
|
18 |
-
log: function () {}
|
19 |
-
};
|
20 |
-
}
|
21 |
-
|
22 |
-
jQuery( function( $ ) {
|
23 |
-
// Debug flag
|
24 |
-
var debugMode = gtm4wp_scrollerscript_debugmode;
|
25 |
-
|
26 |
-
// Default time delay before checking location
|
27 |
-
var callBackTime = gtm4wp_scrollerscript_callbacktime;
|
28 |
-
|
29 |
-
// # px before tracking a reader
|
30 |
-
var readerLocation = gtm4wp_scrollerscript_readerlocation;
|
31 |
-
|
32 |
-
// Set some flags for tracking & execution
|
33 |
-
var timer = 0;
|
34 |
-
var scroller = false;
|
35 |
-
var endContent = false;
|
36 |
-
var didComplete = false;
|
37 |
-
|
38 |
-
// Set some time variables to calculate reading time
|
39 |
-
var startTime = new Date();
|
40 |
-
var beginning = startTime.getTime();
|
41 |
-
var totalTime = 0;
|
42 |
-
|
43 |
-
// Track the aticle load
|
44 |
-
if ( !debugMode ) {
|
45 |
-
window[ gtm4wp_datalayer_name ].push({
|
46 |
-
'event': 'gtm4wp.reading.articleLoaded'
|
47 |
-
});
|
48 |
-
} else {
|
49 |
-
console.log( 'Article loaded' );
|
50 |
-
}
|
51 |
-
|
52 |
-
// Check the location and track user
|
53 |
-
function trackLocation() {
|
54 |
-
bottom = $( window ).height() + $( window ).scrollTop();
|
55 |
-
height = $( document ).height();
|
56 |
-
|
57 |
-
// If user starts to scroll send an event
|
58 |
-
if ( bottom > readerLocation && !scroller ) {
|
59 |
-
currentTime = new Date();
|
60 |
-
scrollStart = currentTime.getTime();
|
61 |
-
timeToScroll = Math.round( ( scrollStart - beginning ) / 1000 );
|
62 |
-
|
63 |
-
if ( !debugMode ) {
|
64 |
-
window[ gtm4wp_datalayer_name ].push({
|
65 |
-
'event': 'gtm4wp.reading.startReading',
|
66 |
-
'timeToScroll': timeToScroll
|
67 |
-
});
|
68 |
-
} else {
|
69 |
-
console.log( 'Started reading ' + timeToScroll );
|
70 |
-
}
|
71 |
-
scroller = true;
|
72 |
-
}
|
73 |
-
|
74 |
-
// If user has hit the bottom of the content send an event
|
75 |
-
if ( bottom >= $( '#' + gtm4wp_scrollerscript_contentelementid ).scrollTop() + $( '#' + gtm4wp_scrollerscript_contentelementid ).innerHeight() && !endContent ) {
|
76 |
-
currentTime = new Date();
|
77 |
-
contentScrollEnd = currentTime.getTime();
|
78 |
-
timeToContentEnd = Math.round( ( contentScrollEnd - scrollStart ) / 1000 );
|
79 |
-
|
80 |
-
if ( !debugMode ) {
|
81 |
-
window[ gtm4wp_datalayer_name ].push({
|
82 |
-
'event': 'gtm4wp.reading.contentBottom',
|
83 |
-
'timeToScroll': timeToContentEnd
|
84 |
-
});
|
85 |
-
} else {
|
86 |
-
console.log( 'End content section ' + timeToContentEnd );
|
87 |
-
}
|
88 |
-
|
89 |
-
endContent = true;
|
90 |
-
}
|
91 |
-
|
92 |
-
// If user has hit the bottom of page send an event
|
93 |
-
if ( bottom >= height && !didComplete ) {
|
94 |
-
currentTime = new Date();
|
95 |
-
end = currentTime.getTime();
|
96 |
-
totalTime = Math.round( ( end - scrollStart ) / 1000 );
|
97 |
-
|
98 |
-
if ( !debugMode ) {
|
99 |
-
if ( totalTime < gtm4wp_scrollerscript_scannertime ) {
|
100 |
-
window[ gtm4wp_datalayer_name ].push({
|
101 |
-
'event': 'gtm4wp.reading.readerType',
|
102 |
-
'readerType': 'scanner'
|
103 |
-
});
|
104 |
-
} else {
|
105 |
-
window[ gtm4wp_datalayer_name ].push({
|
106 |
-
'event': 'gtm4wp.reading.readerType',
|
107 |
-
'readerType': 'reader'
|
108 |
-
});
|
109 |
-
}
|
110 |
-
|
111 |
-
window[ gtm4wp_datalayer_name ].push({
|
112 |
-
'event': 'gtm4wp.reading.pagebottom',
|
113 |
-
'timeToScroll': totalTime
|
114 |
-
});
|
115 |
-
} else {
|
116 |
-
if ( totalTime < gtm4wp_scrollerscript_scannertime ) {
|
117 |
-
console.log( 'The visitor seems to be a "scanner"' );
|
118 |
-
} else {
|
119 |
-
console.log( 'The visitor seems to be a "reader"' );
|
120 |
-
}
|
121 |
-
|
122 |
-
console.log( 'Bottom of page ' + totalTime );
|
123 |
-
}
|
124 |
-
|
125 |
-
didComplete = true;
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
// Track the scrolling and track location
|
130 |
-
$( window ).scroll(function() {
|
131 |
-
if ( timer ) {
|
132 |
-
clearTimeout( timer );
|
133 |
-
}
|
134 |
-
|
135 |
-
// Use a buffer so we don't call trackLocation too often.
|
136 |
-
timer = setTimeout( trackLocation, callBackTime );
|
137 |
-
});
|
138 |
-
});
|
1 |
+
/*
|
2 |
+
* Source: http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/
|
3 |
+
* Original authors:
|
4 |
+
* - Nick Mihailovski
|
5 |
+
* - Thomas Baekdal
|
6 |
+
* - Avinash Kaushik
|
7 |
+
* - Joost de Valk
|
8 |
+
* - Eivind Savio
|
9 |
+
* - Justin Cutroni
|
10 |
+
*
|
11 |
+
* Google Tag Manager dataLayer events added by:
|
12 |
+
* Thomas Geiger
|
13 |
+
* gtm4wp.com
|
14 |
+
*/
|
15 |
+
|
16 |
+
if ( "undefined" == typeof console ) {
|
17 |
+
window.console = {
|
18 |
+
log: function () {}
|
19 |
+
};
|
20 |
+
}
|
21 |
+
|
22 |
+
jQuery( function( $ ) {
|
23 |
+
// Debug flag
|
24 |
+
var debugMode = gtm4wp_scrollerscript_debugmode;
|
25 |
+
|
26 |
+
// Default time delay before checking location
|
27 |
+
var callBackTime = gtm4wp_scrollerscript_callbacktime;
|
28 |
+
|
29 |
+
// # px before tracking a reader
|
30 |
+
var readerLocation = gtm4wp_scrollerscript_readerlocation;
|
31 |
+
|
32 |
+
// Set some flags for tracking & execution
|
33 |
+
var timer = 0;
|
34 |
+
var scroller = false;
|
35 |
+
var endContent = false;
|
36 |
+
var didComplete = false;
|
37 |
+
|
38 |
+
// Set some time variables to calculate reading time
|
39 |
+
var startTime = new Date();
|
40 |
+
var beginning = startTime.getTime();
|
41 |
+
var totalTime = 0;
|
42 |
+
|
43 |
+
// Track the aticle load
|
44 |
+
if ( !debugMode ) {
|
45 |
+
window[ gtm4wp_datalayer_name ].push({
|
46 |
+
'event': 'gtm4wp.reading.articleLoaded'
|
47 |
+
});
|
48 |
+
} else {
|
49 |
+
console.log( 'Article loaded' );
|
50 |
+
}
|
51 |
+
|
52 |
+
// Check the location and track user
|
53 |
+
function trackLocation() {
|
54 |
+
bottom = $( window ).height() + $( window ).scrollTop();
|
55 |
+
height = $( document ).height();
|
56 |
+
|
57 |
+
// If user starts to scroll send an event
|
58 |
+
if ( bottom > readerLocation && !scroller ) {
|
59 |
+
currentTime = new Date();
|
60 |
+
scrollStart = currentTime.getTime();
|
61 |
+
timeToScroll = Math.round( ( scrollStart - beginning ) / 1000 );
|
62 |
+
|
63 |
+
if ( !debugMode ) {
|
64 |
+
window[ gtm4wp_datalayer_name ].push({
|
65 |
+
'event': 'gtm4wp.reading.startReading',
|
66 |
+
'timeToScroll': timeToScroll
|
67 |
+
});
|
68 |
+
} else {
|
69 |
+
console.log( 'Started reading ' + timeToScroll );
|
70 |
+
}
|
71 |
+
scroller = true;
|
72 |
+
}
|
73 |
+
|
74 |
+
// If user has hit the bottom of the content send an event
|
75 |
+
if ( bottom >= $( '#' + gtm4wp_scrollerscript_contentelementid ).scrollTop() + $( '#' + gtm4wp_scrollerscript_contentelementid ).innerHeight() && !endContent ) {
|
76 |
+
currentTime = new Date();
|
77 |
+
contentScrollEnd = currentTime.getTime();
|
78 |
+
timeToContentEnd = Math.round( ( contentScrollEnd - scrollStart ) / 1000 );
|
79 |
+
|
80 |
+
if ( !debugMode ) {
|
81 |
+
window[ gtm4wp_datalayer_name ].push({
|
82 |
+
'event': 'gtm4wp.reading.contentBottom',
|
83 |
+
'timeToScroll': timeToContentEnd
|
84 |
+
});
|
85 |
+
} else {
|
86 |
+
console.log( 'End content section ' + timeToContentEnd );
|
87 |
+
}
|
88 |
+
|
89 |
+
endContent = true;
|
90 |
+
}
|
91 |
+
|
92 |
+
// If user has hit the bottom of page send an event
|
93 |
+
if ( bottom >= height && !didComplete ) {
|
94 |
+
currentTime = new Date();
|
95 |
+
end = currentTime.getTime();
|
96 |
+
totalTime = Math.round( ( end - scrollStart ) / 1000 );
|
97 |
+
|
98 |
+
if ( !debugMode ) {
|
99 |
+
if ( totalTime < gtm4wp_scrollerscript_scannertime ) {
|
100 |
+
window[ gtm4wp_datalayer_name ].push({
|
101 |
+
'event': 'gtm4wp.reading.readerType',
|
102 |
+
'readerType': 'scanner'
|
103 |
+
});
|
104 |
+
} else {
|
105 |
+
window[ gtm4wp_datalayer_name ].push({
|
106 |
+
'event': 'gtm4wp.reading.readerType',
|
107 |
+
'readerType': 'reader'
|
108 |
+
});
|
109 |
+
}
|
110 |
+
|
111 |
+
window[ gtm4wp_datalayer_name ].push({
|
112 |
+
'event': 'gtm4wp.reading.pagebottom',
|
113 |
+
'timeToScroll': totalTime
|
114 |
+
});
|
115 |
+
} else {
|
116 |
+
if ( totalTime < gtm4wp_scrollerscript_scannertime ) {
|
117 |
+
console.log( 'The visitor seems to be a "scanner"' );
|
118 |
+
} else {
|
119 |
+
console.log( 'The visitor seems to be a "reader"' );
|
120 |
+
}
|
121 |
+
|
122 |
+
console.log( 'Bottom of page ' + totalTime );
|
123 |
+
}
|
124 |
+
|
125 |
+
didComplete = true;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
// Track the scrolling and track location
|
130 |
+
$( window ).scroll(function() {
|
131 |
+
if ( timer ) {
|
132 |
+
clearTimeout( timer );
|
133 |
+
}
|
134 |
+
|
135 |
+
// Use a buffer so we don't call trackLocation too often.
|
136 |
+
timer = setTimeout( trackLocation, callBackTime );
|
137 |
+
});
|
138 |
+
});
|
js/froogaloop.js
CHANGED
@@ -1,259 +1,259 @@
|
|
1 |
-
// Init style shamelessly stolen from jQuery http://jquery.com
|
2 |
-
var Froogaloop = (function() {
|
3 |
-
// Define a local copy of Froogaloop
|
4 |
-
function Froogaloop(iframe) {
|
5 |
-
// The Froogaloop object is actually just the init constructor
|
6 |
-
return new Froogaloop.fn.init(iframe);
|
7 |
-
}
|
8 |
-
|
9 |
-
var eventCallbacks = {},
|
10 |
-
hasWindowEvent = false,
|
11 |
-
isReady = false,
|
12 |
-
slice = Array.prototype.slice,
|
13 |
-
playerOrigin = '*';
|
14 |
-
|
15 |
-
Froogaloop.fn = Froogaloop.prototype = {
|
16 |
-
element: null,
|
17 |
-
|
18 |
-
init: function(iframe) {
|
19 |
-
if (typeof iframe === "string") {
|
20 |
-
iframe = document.getElementById(iframe);
|
21 |
-
}
|
22 |
-
|
23 |
-
this.element = iframe;
|
24 |
-
|
25 |
-
return this;
|
26 |
-
},
|
27 |
-
|
28 |
-
/*
|
29 |
-
* Calls a function to act upon the player.
|
30 |
-
*
|
31 |
-
* @param {string} method The name of the Javascript API method to call. Eg: 'play'.
|
32 |
-
* @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
|
33 |
-
* or callback function when the method returns a value.
|
34 |
-
*/
|
35 |
-
api: function(method, valueOrCallback) {
|
36 |
-
if (!this.element || !method) {
|
37 |
-
return false;
|
38 |
-
}
|
39 |
-
|
40 |
-
var self = this,
|
41 |
-
element = self.element,
|
42 |
-
target_id = element.id !== '' ? element.id : null,
|
43 |
-
params = !isFunction(valueOrCallback) ? valueOrCallback : null,
|
44 |
-
callback = isFunction(valueOrCallback) ? valueOrCallback : null;
|
45 |
-
|
46 |
-
// Store the callback for get functions
|
47 |
-
if (callback) {
|
48 |
-
storeCallback(method, callback, target_id);
|
49 |
-
}
|
50 |
-
|
51 |
-
postMessage(method, params, element);
|
52 |
-
return self;
|
53 |
-
},
|
54 |
-
|
55 |
-
/*
|
56 |
-
* Registers an event listener and a callback function that gets called when the event fires.
|
57 |
-
*
|
58 |
-
* @param eventName (String): Name of the event to listen for.
|
59 |
-
* @param callback (Function): Function that should be called when the event fires.
|
60 |
-
*/
|
61 |
-
addEvent: function(eventName, callback) {
|
62 |
-
if (!this.element) {
|
63 |
-
return false;
|
64 |
-
}
|
65 |
-
|
66 |
-
var self = this,
|
67 |
-
element = self.element,
|
68 |
-
target_id = element.id !== '' ? element.id : null;
|
69 |
-
|
70 |
-
|
71 |
-
storeCallback(eventName, callback, target_id);
|
72 |
-
|
73 |
-
// The ready event is not registered via postMessage. It fires regardless.
|
74 |
-
if (eventName != 'ready') {
|
75 |
-
postMessage('addEventListener', eventName, element);
|
76 |
-
} else if (eventName == 'ready' && isReady) {
|
77 |
-
callback.call(null, target_id);
|
78 |
-
}
|
79 |
-
|
80 |
-
return self;
|
81 |
-
},
|
82 |
-
|
83 |
-
/*
|
84 |
-
* Unregisters an event listener that gets called when the event fires.
|
85 |
-
*
|
86 |
-
* @param eventName (String): Name of the event to stop listening for.
|
87 |
-
*/
|
88 |
-
removeEvent: function(eventName) {
|
89 |
-
if (!this.element) {
|
90 |
-
return false;
|
91 |
-
}
|
92 |
-
|
93 |
-
var self = this,
|
94 |
-
element = self.element,
|
95 |
-
target_id = element.id !== '' ? element.id : null,
|
96 |
-
removed = removeCallback(eventName, target_id);
|
97 |
-
|
98 |
-
// The ready event is not registered
|
99 |
-
if (eventName != 'ready' && removed) {
|
100 |
-
postMessage('removeEventListener', eventName, element);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
};
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Handles posting a message to the parent window.
|
107 |
-
*
|
108 |
-
* @param method (String): name of the method to call inside the player. For api calls
|
109 |
-
* this is the name of the api method (api_play or api_pause) while for events this method
|
110 |
-
* is api_addEventListener.
|
111 |
-
* @param params (Object or Array): List of parameters to submit to the method. Can be either
|
112 |
-
* a single param or an array list of parameters.
|
113 |
-
* @param target (HTMLElement): Target iframe to post the message to.
|
114 |
-
*/
|
115 |
-
|
116 |
-
function postMessage(method, params, target) {
|
117 |
-
if (!target.contentWindow.postMessage) {
|
118 |
-
return false;
|
119 |
-
}
|
120 |
-
|
121 |
-
var data = JSON.stringify({
|
122 |
-
method: method,
|
123 |
-
value: params
|
124 |
-
});
|
125 |
-
|
126 |
-
target.contentWindow.postMessage(data, playerOrigin);
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Event that fires whenever the window receives a message from its parent
|
131 |
-
* via window.postMessage.
|
132 |
-
*/
|
133 |
-
|
134 |
-
function onMessageReceived(event) {
|
135 |
-
var data, method;
|
136 |
-
|
137 |
-
try {
|
138 |
-
data = JSON.parse(event.data);
|
139 |
-
method = data.event || data.method;
|
140 |
-
} catch (e) {
|
141 |
-
//fail silently... like a ninja!
|
142 |
-
}
|
143 |
-
|
144 |
-
if (method == 'ready' && !isReady) {
|
145 |
-
isReady = true;
|
146 |
-
}
|
147 |
-
|
148 |
-
// Handles messages from the vimeo player only
|
149 |
-
if (!(/^https?:\/\/player.vimeo.com/).test(event.origin)) {
|
150 |
-
return false;
|
151 |
-
}
|
152 |
-
|
153 |
-
if (playerOrigin === '*') {
|
154 |
-
playerOrigin = event.origin;
|
155 |
-
}
|
156 |
-
|
157 |
-
var value = data.value,
|
158 |
-
eventData = data.data,
|
159 |
-
target_id = target_id === '' ? null : data.player_id,
|
160 |
-
|
161 |
-
callback = getCallback(method, target_id),
|
162 |
-
params = [];
|
163 |
-
|
164 |
-
if (!callback) {
|
165 |
-
return false;
|
166 |
-
}
|
167 |
-
|
168 |
-
if (value !== undefined) {
|
169 |
-
params.push(value);
|
170 |
-
}
|
171 |
-
|
172 |
-
if (eventData) {
|
173 |
-
params.push(eventData);
|
174 |
-
}
|
175 |
-
|
176 |
-
if (target_id) {
|
177 |
-
params.push(target_id);
|
178 |
-
}
|
179 |
-
|
180 |
-
return params.length > 0 ? callback.apply(null, params) : callback.call();
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Stores submitted callbacks for each iframe being tracked and each
|
186 |
-
* event for that iframe.
|
187 |
-
*
|
188 |
-
* @param eventName (String): Name of the event. Eg. api_onPlay
|
189 |
-
* @param callback (Function): Function that should get executed when the
|
190 |
-
* event is fired.
|
191 |
-
* @param target_id (String) [Optional]: If handling more than one iframe then
|
192 |
-
* it stores the different callbacks for different iframes based on the iframe's
|
193 |
-
* id.
|
194 |
-
*/
|
195 |
-
|
196 |
-
function storeCallback(eventName, callback, target_id) {
|
197 |
-
if (target_id) {
|
198 |
-
if (!eventCallbacks[target_id]) {
|
199 |
-
eventCallbacks[target_id] = {};
|
200 |
-
}
|
201 |
-
eventCallbacks[target_id][eventName] = callback;
|
202 |
-
} else {
|
203 |
-
eventCallbacks[eventName] = callback;
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Retrieves stored callbacks.
|
209 |
-
*/
|
210 |
-
|
211 |
-
function getCallback(eventName, target_id) {
|
212 |
-
if (target_id) {
|
213 |
-
return eventCallbacks[target_id][eventName];
|
214 |
-
} else {
|
215 |
-
return eventCallbacks[eventName];
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
function removeCallback(eventName, target_id) {
|
220 |
-
if (target_id && eventCallbacks[target_id]) {
|
221 |
-
if (!eventCallbacks[target_id][eventName]) {
|
222 |
-
return false;
|
223 |
-
}
|
224 |
-
eventCallbacks[target_id][eventName] = null;
|
225 |
-
} else {
|
226 |
-
if (!eventCallbacks[eventName]) {
|
227 |
-
return false;
|
228 |
-
}
|
229 |
-
eventCallbacks[eventName] = null;
|
230 |
-
}
|
231 |
-
|
232 |
-
return true;
|
233 |
-
}
|
234 |
-
|
235 |
-
function isFunction(obj) {
|
236 |
-
return !!(obj && obj.constructor && obj.call && obj.apply);
|
237 |
-
}
|
238 |
-
|
239 |
-
function isArray(obj) {
|
240 |
-
return toString.call(obj) === '[object Array]';
|
241 |
-
}
|
242 |
-
|
243 |
-
// Give the init function the Froogaloop prototype for later instantiation
|
244 |
-
Froogaloop.fn.init.prototype = Froogaloop.fn;
|
245 |
-
|
246 |
-
// Listens for the message event.
|
247 |
-
// W3C
|
248 |
-
if (window.addEventListener) {
|
249 |
-
window.addEventListener('message', onMessageReceived, false);
|
250 |
-
}
|
251 |
-
// IE
|
252 |
-
else {
|
253 |
-
window.attachEvent('onmessage', onMessageReceived);
|
254 |
-
}
|
255 |
-
|
256 |
-
// Expose froogaloop to the global object
|
257 |
-
return (window.Froogaloop = window.$f = Froogaloop);
|
258 |
-
|
259 |
-
})();
|
1 |
+
// Init style shamelessly stolen from jQuery http://jquery.com
|
2 |
+
var Froogaloop = (function() {
|
3 |
+
// Define a local copy of Froogaloop
|
4 |
+
function Froogaloop(iframe) {
|
5 |
+
// The Froogaloop object is actually just the init constructor
|
6 |
+
return new Froogaloop.fn.init(iframe);
|
7 |
+
}
|
8 |
+
|
9 |
+
var eventCallbacks = {},
|
10 |
+
hasWindowEvent = false,
|
11 |
+
isReady = false,
|
12 |
+
slice = Array.prototype.slice,
|
13 |
+
playerOrigin = '*';
|
14 |
+
|
15 |
+
Froogaloop.fn = Froogaloop.prototype = {
|
16 |
+
element: null,
|
17 |
+
|
18 |
+
init: function(iframe) {
|
19 |
+
if (typeof iframe === "string") {
|
20 |
+
iframe = document.getElementById(iframe);
|
21 |
+
}
|
22 |
+
|
23 |
+
this.element = iframe;
|
24 |
+
|
25 |
+
return this;
|
26 |
+
},
|
27 |
+
|
28 |
+
/*
|
29 |
+
* Calls a function to act upon the player.
|
30 |
+
*
|
31 |
+
* @param {string} method The name of the Javascript API method to call. Eg: 'play'.
|
32 |
+
* @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
|
33 |
+
* or callback function when the method returns a value.
|
34 |
+
*/
|
35 |
+
api: function(method, valueOrCallback) {
|
36 |
+
if (!this.element || !method) {
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
|
40 |
+
var self = this,
|
41 |
+
element = self.element,
|
42 |
+
target_id = element.id !== '' ? element.id : null,
|
43 |
+
params = !isFunction(valueOrCallback) ? valueOrCallback : null,
|
44 |
+
callback = isFunction(valueOrCallback) ? valueOrCallback : null;
|
45 |
+
|
46 |
+
// Store the callback for get functions
|
47 |
+
if (callback) {
|
48 |
+
storeCallback(method, callback, target_id);
|
49 |
+
}
|
50 |
+
|
51 |
+
postMessage(method, params, element);
|
52 |
+
return self;
|
53 |
+
},
|
54 |
+
|
55 |
+
/*
|
56 |
+
* Registers an event listener and a callback function that gets called when the event fires.
|
57 |
+
*
|
58 |
+
* @param eventName (String): Name of the event to listen for.
|
59 |
+
* @param callback (Function): Function that should be called when the event fires.
|
60 |
+
*/
|
61 |
+
addEvent: function(eventName, callback) {
|
62 |
+
if (!this.element) {
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
var self = this,
|
67 |
+
element = self.element,
|
68 |
+
target_id = element.id !== '' ? element.id : null;
|
69 |
+
|
70 |
+
|
71 |
+
storeCallback(eventName, callback, target_id);
|
72 |
+
|
73 |
+
// The ready event is not registered via postMessage. It fires regardless.
|
74 |
+
if (eventName != 'ready') {
|
75 |
+
postMessage('addEventListener', eventName, element);
|
76 |
+
} else if (eventName == 'ready' && isReady) {
|
77 |
+
callback.call(null, target_id);
|
78 |
+
}
|
79 |
+
|
80 |
+
return self;
|
81 |
+
},
|
82 |
+
|
83 |
+
/*
|
84 |
+
* Unregisters an event listener that gets called when the event fires.
|
85 |
+
*
|
86 |
+
* @param eventName (String): Name of the event to stop listening for.
|
87 |
+
*/
|
88 |
+
removeEvent: function(eventName) {
|
89 |
+
if (!this.element) {
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
var self = this,
|
94 |
+
element = self.element,
|
95 |
+
target_id = element.id !== '' ? element.id : null,
|
96 |
+
removed = removeCallback(eventName, target_id);
|
97 |
+
|
98 |
+
// The ready event is not registered
|
99 |
+
if (eventName != 'ready' && removed) {
|
100 |
+
postMessage('removeEventListener', eventName, element);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
};
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Handles posting a message to the parent window.
|
107 |
+
*
|
108 |
+
* @param method (String): name of the method to call inside the player. For api calls
|
109 |
+
* this is the name of the api method (api_play or api_pause) while for events this method
|
110 |
+
* is api_addEventListener.
|
111 |
+
* @param params (Object or Array): List of parameters to submit to the method. Can be either
|
112 |
+
* a single param or an array list of parameters.
|
113 |
+
* @param target (HTMLElement): Target iframe to post the message to.
|
114 |
+
*/
|
115 |
+
|
116 |
+
function postMessage(method, params, target) {
|
117 |
+
if (!target.contentWindow.postMessage) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
var data = JSON.stringify({
|
122 |
+
method: method,
|
123 |
+
value: params
|
124 |
+
});
|
125 |
+
|
126 |
+
target.contentWindow.postMessage(data, playerOrigin);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Event that fires whenever the window receives a message from its parent
|
131 |
+
* via window.postMessage.
|
132 |
+
*/
|
133 |
+
|
134 |
+
function onMessageReceived(event) {
|
135 |
+
var data, method;
|
136 |
+
|
137 |
+
try {
|
138 |
+
data = JSON.parse(event.data);
|
139 |
+
method = data.event || data.method;
|
140 |
+
} catch (e) {
|
141 |
+
//fail silently... like a ninja!
|
142 |
+
}
|
143 |
+
|
144 |
+
if (method == 'ready' && !isReady) {
|
145 |
+
isReady = true;
|
146 |
+
}
|
147 |
+
|
148 |
+
// Handles messages from the vimeo player only
|
149 |
+
if (!(/^https?:\/\/player.vimeo.com/).test(event.origin)) {
|
150 |
+
return false;
|
151 |
+
}
|
152 |
+
|
153 |
+
if (playerOrigin === '*') {
|
154 |
+
playerOrigin = event.origin;
|
155 |
+
}
|
156 |
+
|
157 |
+
var value = data.value,
|
158 |
+
eventData = data.data,
|
159 |
+
target_id = target_id === '' ? null : data.player_id,
|
160 |
+
|
161 |
+
callback = getCallback(method, target_id),
|
162 |
+
params = [];
|
163 |
+
|
164 |
+
if (!callback) {
|
165 |
+
return false;
|
166 |
+
}
|
167 |
+
|
168 |
+
if (value !== undefined) {
|
169 |
+
params.push(value);
|
170 |
+
}
|
171 |
+
|
172 |
+
if (eventData) {
|
173 |
+
params.push(eventData);
|
174 |
+
}
|
175 |
+
|
176 |
+
if (target_id) {
|
177 |
+
params.push(target_id);
|
178 |
+
}
|
179 |
+
|
180 |
+
return params.length > 0 ? callback.apply(null, params) : callback.call();
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Stores submitted callbacks for each iframe being tracked and each
|
186 |
+
* event for that iframe.
|
187 |
+
*
|
188 |
+
* @param eventName (String): Name of the event. Eg. api_onPlay
|
189 |
+
* @param callback (Function): Function that should get executed when the
|
190 |
+
* event is fired.
|
191 |
+
* @param target_id (String) [Optional]: If handling more than one iframe then
|
192 |
+
* it stores the different callbacks for different iframes based on the iframe's
|
193 |
+
* id.
|
194 |
+
*/
|
195 |
+
|
196 |
+
function storeCallback(eventName, callback, target_id) {
|
197 |
+
if (target_id) {
|
198 |
+
if (!eventCallbacks[target_id]) {
|
199 |
+
eventCallbacks[target_id] = {};
|
200 |
+
}
|
201 |
+
eventCallbacks[target_id][eventName] = callback;
|
202 |
+
} else {
|
203 |
+
eventCallbacks[eventName] = callback;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Retrieves stored callbacks.
|
209 |
+
*/
|
210 |
+
|
211 |
+
function getCallback(eventName, target_id) {
|
212 |
+
if (target_id) {
|
213 |
+
return eventCallbacks[target_id][eventName];
|
214 |
+
} else {
|
215 |
+
return eventCallbacks[eventName];
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
function removeCallback(eventName, target_id) {
|
220 |
+
if (target_id && eventCallbacks[target_id]) {
|
221 |
+
if (!eventCallbacks[target_id][eventName]) {
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
eventCallbacks[target_id][eventName] = null;
|
225 |
+
} else {
|
226 |
+
if (!eventCallbacks[eventName]) {
|
227 |
+
return false;
|
228 |
+
}
|
229 |
+
eventCallbacks[eventName] = null;
|
230 |
+
}
|
231 |
+
|
232 |
+
return true;
|
233 |
+
}
|
234 |
+
|
235 |
+
function isFunction(obj) {
|
236 |
+
return !!(obj && obj.constructor && obj.call && obj.apply);
|
237 |
+
}
|
238 |
+
|
239 |
+
function isArray(obj) {
|
240 |
+
return toString.call(obj) === '[object Array]';
|
241 |
+
}
|
242 |
+
|
243 |
+
// Give the init function the Froogaloop prototype for later instantiation
|
244 |
+
Froogaloop.fn.init.prototype = Froogaloop.fn;
|
245 |
+
|
246 |
+
// Listens for the message event.
|
247 |
+
// W3C
|
248 |
+
if (window.addEventListener) {
|
249 |
+
window.addEventListener('message', onMessageReceived, false);
|
250 |
+
}
|
251 |
+
// IE
|
252 |
+
else {
|
253 |
+
window.attachEvent('onmessage', onMessageReceived);
|
254 |
+
}
|
255 |
+
|
256 |
+
// Expose froogaloop to the global object
|
257 |
+
return (window.Froogaloop = window.$f = Froogaloop);
|
258 |
+
|
259 |
+
})();
|
js/gtm4wp-contact-form-7-tracker.js
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
jQuery( function() {
|
2 |
-
jQuery( ".wpcf7" )
|
3 |
-
.on( 'wpcf7mailsent', function( e ) {
|
4 |
-
var gtm4wp_cf7formid = '(not set)';
|
5 |
-
if ( e && e.detail && e.detail.contactFormId ) {
|
6 |
-
gtm4wp_cf7formid = e.detail.contactFormId;
|
7 |
-
} else if ( e && e.originalEvent && e.originalEvent.detail && e.originalEvent.detail.contactFormId ) {
|
8 |
-
gtm4wp_cf7formid = e.originalEvent.detail.contactFormId;
|
9 |
-
}
|
10 |
-
|
11 |
-
var gtm4wp_cf7forminputs = [];
|
12 |
-
if ( e && e.detail && e.detail.inputs ) {
|
13 |
-
gtm4wp_cf7forminputs = e.detail.inputs;
|
14 |
-
} else if ( e && e.originalEvent && e.originalEvent.detail && e.originalEvent.detail.inputs ) {
|
15 |
-
gtm4wp_cf7forminputs = e.originalEvent.detail.inputs;
|
16 |
-
}
|
17 |
-
|
18 |
-
window[ gtm4wp_datalayer_name ].push({
|
19 |
-
'event': 'gtm4wp.contactForm7Submitted',
|
20 |
-
'gtm4wp.cf7formid': gtm4wp_cf7formid,
|
21 |
-
'gtm4wp.cf7inputs': gtm4wp_cf7forminputs
|
22 |
-
});
|
23 |
-
});
|
24 |
-
});
|
1 |
+
jQuery( function() {
|
2 |
+
jQuery( ".wpcf7" )
|
3 |
+
.on( 'wpcf7mailsent', function( e ) {
|
4 |
+
var gtm4wp_cf7formid = '(not set)';
|
5 |
+
if ( e && e.detail && e.detail.contactFormId ) {
|
6 |
+
gtm4wp_cf7formid = e.detail.contactFormId;
|
7 |
+
} else if ( e && e.originalEvent && e.originalEvent.detail && e.originalEvent.detail.contactFormId ) {
|
8 |
+
gtm4wp_cf7formid = e.originalEvent.detail.contactFormId;
|
9 |
+
}
|
10 |
+
|
11 |
+
var gtm4wp_cf7forminputs = [];
|
12 |
+
if ( e && e.detail && e.detail.inputs ) {
|
13 |
+
gtm4wp_cf7forminputs = e.detail.inputs;
|
14 |
+
} else if ( e && e.originalEvent && e.originalEvent.detail && e.originalEvent.detail.inputs ) {
|
15 |
+
gtm4wp_cf7forminputs = e.originalEvent.detail.inputs;
|
16 |
+
}
|
17 |
+
|
18 |
+
window[ gtm4wp_datalayer_name ].push({
|
19 |
+
'event': 'gtm4wp.contactForm7Submitted',
|
20 |
+
'gtm4wp.cf7formid': gtm4wp_cf7formid,
|
21 |
+
'gtm4wp.cf7inputs': gtm4wp_cf7forminputs
|
22 |
+
});
|
23 |
+
});
|
24 |
+
});
|
js/gtm4wp-download-tracker.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
function gtm4wp_track_downloads(track_extensions) {
|
2 |
-
var gtm4wp_extensions_to_track = track_extensions.split(",");
|
3 |
-
|
4 |
-
for ( var i = 0; i < gtm4wp_extensions_to_track.length; i++ ) {
|
5 |
-
jQuery( "a[href$=\\." + gtm4wp_extensions_to_track[i].toLowerCase() + "], a[href$=\\." + gtm4wp_extensions_to_track[i].toUpperCase() + "]" )
|
6 |
-
.on( "click", function() {
|
7 |
-
window[ gtm4wp_datalayer_name ].push({
|
8 |
-
'event': 'gtm4wp.downloadClick',
|
9 |
-
'linkhref': jQuery( this ).attr( "href" )
|
10 |
-
});
|
11 |
-
})
|
12 |
-
.attr( "target", "_blank" );
|
13 |
-
} // end for i
|
14 |
-
}
|
1 |
+
function gtm4wp_track_downloads(track_extensions) {
|
2 |
+
var gtm4wp_extensions_to_track = track_extensions.split(",");
|
3 |
+
|
4 |
+
for ( var i = 0; i < gtm4wp_extensions_to_track.length; i++ ) {
|
5 |
+
jQuery( "a[href$=\\." + gtm4wp_extensions_to_track[i].toLowerCase() + "], a[href$=\\." + gtm4wp_extensions_to_track[i].toUpperCase() + "]" )
|
6 |
+
.on( "click", function() {
|
7 |
+
window[ gtm4wp_datalayer_name ].push({
|
8 |
+
'event': 'gtm4wp.downloadClick',
|
9 |
+
'linkhref': jQuery( this ).attr( "href" )
|
10 |
+
});
|
11 |
+
})
|
12 |
+
.attr( "target", "_blank" );
|
13 |
+
} // end for i
|
14 |
+
}
|
js/gtm4wp-email-link-tracker.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
jQuery( function() {
|
2 |
-
jQuery( "a[href^=mailto]" )
|
3 |
-
.on( "click", function() {
|
4 |
-
var gtm4wp_linkparts = jQuery( this ).attr( "href" ).split( ":" );
|
5 |
-
|
6 |
-
window[ gtm4wp_datalayer_name ].push({
|
7 |
-
'event': 'gtm4wp.emailClick',
|
8 |
-
'linkhref': gtm4wp_linkparts
|
9 |
-
});
|
10 |
-
})
|
11 |
-
.attr( "target", "_blank" );
|
12 |
-
});
|
1 |
+
jQuery( function() {
|
2 |
+
jQuery( "a[href^=mailto]" )
|
3 |
+
.on( "click", function() {
|
4 |
+
var gtm4wp_linkparts = jQuery( this ).attr( "href" ).split( ":" );
|
5 |
+
|
6 |
+
window[ gtm4wp_datalayer_name ].push({
|
7 |
+
'event': 'gtm4wp.emailClick',
|
8 |
+
'linkhref': gtm4wp_linkparts
|
9 |
+
});
|
10 |
+
})
|
11 |
+
.attr( "target", "_blank" );
|
12 |
+
});
|
js/gtm4wp-form-move-tracker.js
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
jQuery( function() {
|
2 |
-
jQuery( ":input" )
|
3 |
-
.on( "focus", function() {
|
4 |
-
var input = jQuery(this);
|
5 |
-
var inputID = input.attr("id") || "(no input ID)";
|
6 |
-
var inputName = input.attr("name") || "(no input name)";
|
7 |
-
var inputClass = input.attr("class") || "(no input class)";
|
8 |
-
|
9 |
-
var form = jQuery(this.form);
|
10 |
-
var formID = form.attr("id") || "(no form ID)";
|
11 |
-
var formName = form.attr("name") || "(no form name)";
|
12 |
-
var formClass = form.attr("class") || "(no form class)";
|
13 |
-
|
14 |
-
window[ gtm4wp_datalayer_name ].push({
|
15 |
-
'event' : 'gtm4wp.formElementEnter',
|
16 |
-
|
17 |
-
'inputID' : inputID,
|
18 |
-
'inputName' : inputName,
|
19 |
-
'inputClass': inputClass,
|
20 |
-
|
21 |
-
'formID' : formID,
|
22 |
-
'formName' : formName,
|
23 |
-
'formClass': formClass
|
24 |
-
});
|
25 |
-
})
|
26 |
-
|
27 |
-
.on( "blur", function() {
|
28 |
-
var input = jQuery(this);
|
29 |
-
var inputID = input.attr("id") || "(no input ID)";
|
30 |
-
var inputName = input.attr("name") || "(no input name)";
|
31 |
-
var inputClass = input.attr("class") || "(no input class)";
|
32 |
-
|
33 |
-
var form = jQuery(this.form);
|
34 |
-
var formID = form.attr("id") || "(no form ID)";
|
35 |
-
var formName = form.attr("name") || "(no form name)";
|
36 |
-
var formClass = form.attr("class") || "(no form class)";
|
37 |
-
|
38 |
-
window[ gtm4wp_datalayer_name ].push({
|
39 |
-
'event' : 'gtm4wp.formElementLeave',
|
40 |
-
|
41 |
-
'inputID' : inputID,
|
42 |
-
'inputName' : inputName,
|
43 |
-
'inputClass': inputClass,
|
44 |
-
|
45 |
-
'formID' : formID,
|
46 |
-
'formName' : formName,
|
47 |
-
'formClass': formClass
|
48 |
-
});
|
49 |
-
});
|
50 |
-
});
|
1 |
+
jQuery( function() {
|
2 |
+
jQuery( ":input" )
|
3 |
+
.on( "focus", function() {
|
4 |
+
var input = jQuery(this);
|
5 |
+
var inputID = input.attr("id") || "(no input ID)";
|
6 |
+
var inputName = input.attr("name") || "(no input name)";
|
7 |
+
var inputClass = input.attr("class") || "(no input class)";
|
8 |
+
|
9 |
+
var form = jQuery(this.form);
|
10 |
+
var formID = form.attr("id") || "(no form ID)";
|
11 |
+
var formName = form.attr("name") || "(no form name)";
|
12 |
+
var formClass = form.attr("class") || "(no form class)";
|
13 |
+
|
14 |
+
window[ gtm4wp_datalayer_name ].push({
|
15 |
+
'event' : 'gtm4wp.formElementEnter',
|
16 |
+
|
17 |
+
'inputID' : inputID,
|
18 |
+
'inputName' : inputName,
|
19 |
+
'inputClass': inputClass,
|
20 |
+
|
21 |
+
'formID' : formID,
|
22 |
+
'formName' : formName,
|
23 |
+
'formClass': formClass
|
24 |
+
});
|
25 |
+
})
|
26 |
+
|
27 |
+
.on( "blur", function() {
|
28 |
+
var input = jQuery(this);
|
29 |
+
var inputID = input.attr("id") || "(no input ID)";
|
30 |
+
var inputName = input.attr("name") || "(no input name)";
|
31 |
+
var inputClass = input.attr("class") || "(no input class)";
|
32 |
+
|
33 |
+
var form = jQuery(this.form);
|
34 |
+
var formID = form.attr("id") || "(no form ID)";
|
35 |
+
var formName = form.attr("name") || "(no form name)";
|
36 |
+
var formClass = form.attr("class") || "(no form class)";
|
37 |
+
|
38 |
+
window[ gtm4wp_datalayer_name ].push({
|
39 |
+
'event' : 'gtm4wp.formElementLeave',
|
40 |
+
|
41 |
+
'inputID' : inputID,
|
42 |
+
'inputName' : inputName,
|
43 |
+
'inputClass': inputClass,
|
44 |
+
|
45 |
+
'formID' : formID,
|
46 |
+
'formName' : formName,
|
47 |
+
'formClass': formClass
|
48 |
+
});
|
49 |
+
});
|
50 |
+
});
|
js/gtm4wp-outbound-click-tracker.js
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
jQuery( function() {
|
2 |
-
var gtm4wp_localdomain = window.location.hostname.replace( "www.", "" );
|
3 |
-
|
4 |
-
jQuery( "a[href^=http]" )
|
5 |
-
.each( function() {
|
6 |
-
var gtm4wp_linkhref = jQuery( this ).attr( "href" );
|
7 |
-
|
8 |
-
if ( gtm4wp_linkhref.indexOf( gtm4wp_localdomain ) == -1 ) {
|
9 |
-
jQuery( this )
|
10 |
-
.on( "click", function() {
|
11 |
-
window[ gtm4wp_datalayer_name ].push({
|
12 |
-
'event': 'gtm4wp.outboundClick',
|
13 |
-
'linkhref': jQuery( this ).attr( "href" )
|
14 |
-
});
|
15 |
-
})
|
16 |
-
.attr( "target", "_blank" );
|
17 |
-
}
|
18 |
-
});
|
19 |
-
});
|
1 |
+
jQuery( function() {
|
2 |
+
var gtm4wp_localdomain = window.location.hostname.replace( "www.", "" );
|
3 |
+
|
4 |
+
jQuery( "a[href^=http]" )
|
5 |
+
.each( function() {
|
6 |
+
var gtm4wp_linkhref = jQuery( this ).attr( "href" );
|
7 |
+
|
8 |
+
if ( gtm4wp_linkhref.indexOf( gtm4wp_localdomain ) == -1 ) {
|
9 |
+
jQuery( this )
|
10 |
+
.on( "click", function() {
|
11 |
+
window[ gtm4wp_datalayer_name ].push({
|
12 |
+
'event': 'gtm4wp.outboundClick',
|
13 |
+
'linkhref': jQuery( this ).attr( "href" )
|
14 |
+
});
|
15 |
+
})
|
16 |
+
.attr( "target", "_blank" );
|
17 |
+
}
|
18 |
+
});
|
19 |
+
});
|
js/gtm4wp-social-tracker.js
CHANGED
@@ -1,97 +1,107 @@
|
|
1 |
-
jQuery( function() {
|
2 |
-
if ( typeof FB != "undefined" ) {
|
3 |
-
FB.Event.subscribe( 'edge.create', function( href, widget ) {
|
4 |
-
window[ gtm4wp_datalayer_name ].push({
|
5 |
-
'event': 'gtm4wp.socialAction',
|
6 |
-
'network': 'facebook',
|
7 |
-
'socialAction': 'like',
|
8 |
-
'opt_target': href,
|
9 |
-
'opt_pagePath': window.location.href
|
10 |
-
});
|
11 |
-
});
|
12 |
-
|
13 |
-
FB.Event.subscribe( 'edge.remove', function( href, widget ) {
|
14 |
-
window[ gtm4wp_datalayer_name ].push({
|
15 |
-
'event': 'gtm4wp.socialAction',
|
16 |
-
'network': 'facebook',
|
17 |
-
'socialAction': 'unlike',
|
18 |
-
'opt_target': href,
|
19 |
-
'opt_pagePath': window.location.href
|
20 |
-
});
|
21 |
-
});
|
22 |
-
|
23 |
-
FB.Event.subscribe( 'comment.create', function( href, commentID ) {
|
24 |
-
window[ gtm4wp_datalayer_name ].push({
|
25 |
-
'event': 'gtm4wp.socialAction',
|
26 |
-
'network': 'facebook',
|
27 |
-
'socialAction': 'comment',
|
28 |
-
'opt_target': href,
|
29 |
-
'opt_pagePath': window.location.href
|
30 |
-
});
|
31 |
-
});
|
32 |
-
|
33 |
-
FB.Event.subscribe( 'comment.remove', function( href, commentID ) {
|
34 |
-
window[ gtm4wp_datalayer_name ].push({
|
35 |
-
'event': 'gtm4wp.socialAction',
|
36 |
-
'network': 'facebook',
|
37 |
-
'socialAction': 'uncomment',
|
38 |
-
'opt_target': href,
|
39 |
-
'opt_pagePath': window.location.href
|
40 |
-
});
|
41 |
-
});
|
42 |
-
|
43 |
-
FB.Event.subscribe( 'message.send', function( response ) {
|
44 |
-
window[ gtm4wp_datalayer_name ].push({
|
45 |
-
'event': 'gtm4wp.socialAction',
|
46 |
-
'network': 'facebook',
|
47 |
-
'socialAction': 'send',
|
48 |
-
'opt_target': response,
|
49 |
-
'opt_pagePath': window.location.href
|
50 |
-
});
|
51 |
-
});
|
52 |
-
} // end of Facebook social events
|
53 |
-
|
54 |
-
if ( typeof window.twttr == "undefined" ) {
|
55 |
-
window.twttr = (function ( d, s, id ) {
|
56 |
-
var t, js, fjs = d.getElementsByTagName(s)[0];
|
57 |
-
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
|
58 |
-
js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function() {
|
2 |
+
if ( typeof FB != "undefined" ) {
|
3 |
+
FB.Event.subscribe( 'edge.create', function( href, widget ) {
|
4 |
+
window[ gtm4wp_datalayer_name ].push({
|
5 |
+
'event': 'gtm4wp.socialAction',
|
6 |
+
'network': 'facebook',
|
7 |
+
'socialAction': 'like',
|
8 |
+
'opt_target': href,
|
9 |
+
'opt_pagePath': window.location.href
|
10 |
+
});
|
11 |
+
});
|
12 |
+
|
13 |
+
FB.Event.subscribe( 'edge.remove', function( href, widget ) {
|
14 |
+
window[ gtm4wp_datalayer_name ].push({
|
15 |
+
'event': 'gtm4wp.socialAction',
|
16 |
+
'network': 'facebook',
|
17 |
+
'socialAction': 'unlike',
|
18 |
+
'opt_target': href,
|
19 |
+
'opt_pagePath': window.location.href
|
20 |
+
});
|
21 |
+
});
|
22 |
+
|
23 |
+
FB.Event.subscribe( 'comment.create', function( href, commentID ) {
|
24 |
+
window[ gtm4wp_datalayer_name ].push({
|
25 |
+
'event': 'gtm4wp.socialAction',
|
26 |
+
'network': 'facebook',
|
27 |
+
'socialAction': 'comment',
|
28 |
+
'opt_target': href,
|
29 |
+
'opt_pagePath': window.location.href
|
30 |
+
});
|
31 |
+
});
|
32 |
+
|
33 |
+
FB.Event.subscribe( 'comment.remove', function( href, commentID ) {
|
34 |
+
window[ gtm4wp_datalayer_name ].push({
|
35 |
+
'event': 'gtm4wp.socialAction',
|
36 |
+
'network': 'facebook',
|
37 |
+
'socialAction': 'uncomment',
|
38 |
+
'opt_target': href,
|
39 |
+
'opt_pagePath': window.location.href
|
40 |
+
});
|
41 |
+
});
|
42 |
+
|
43 |
+
FB.Event.subscribe( 'message.send', function( response ) {
|
44 |
+
window[ gtm4wp_datalayer_name ].push({
|
45 |
+
'event': 'gtm4wp.socialAction',
|
46 |
+
'network': 'facebook',
|
47 |
+
'socialAction': 'send',
|
48 |
+
'opt_target': response,
|
49 |
+
'opt_pagePath': window.location.href
|
50 |
+
});
|
51 |
+
});
|
52 |
+
} // end of Facebook social events
|
53 |
+
|
54 |
+
if ( typeof window.twttr == "undefined" ) {
|
55 |
+
window.twttr = (function ( d, s, id ) {
|
56 |
+
var t, js, fjs = d.getElementsByTagName(s)[0];
|
57 |
+
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
|
58 |
+
js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
|
59 |
+
return window.twttr || (t = {
|
60 |
+
_e: [],
|
61 |
+
ready: function(f) {
|
62 |
+
t._e.push(f);
|
63 |
+
}
|
64 |
+
});
|
65 |
+
} (document, "script", "twitter-wjs"));
|
66 |
+
} // end of loading Twitter JS
|
67 |
+
|
68 |
+
if ( typeof window.twttr != "undefined" ) {
|
69 |
+
window.twttr.ready(function ( twttr ) {
|
70 |
+
twttr.events.bind( 'tweet', function ( intent_event ) {
|
71 |
+
if ( intent_event ) {
|
72 |
+
var label = intent_event.data.tweet_id;
|
73 |
+
|
74 |
+
if (typeof label != 'undefined' && label) {
|
75 |
+
if(label == 'label'){
|
76 |
+
label = window.location.href;
|
77 |
+
}
|
78 |
+
}else{
|
79 |
+
label = window.location.href;
|
80 |
+
}
|
81 |
+
|
82 |
+
window[ gtm4wp_datalayer_name ].push({
|
83 |
+
'event': 'gtm4wp.socialAction',
|
84 |
+
'network': 'twitter',
|
85 |
+
'socialAction': 'tweet',
|
86 |
+
'opt_target': label,
|
87 |
+
'opt_pagePath': window.location.href
|
88 |
+
});
|
89 |
+
}
|
90 |
+
});
|
91 |
+
|
92 |
+
window.twttr.events.bind( 'follow', function ( intent_event ) {
|
93 |
+
if ( intent_event ) {
|
94 |
+
var label = intent_event.data.user_id + " (" + intent_event.data.screen_name + ")";
|
95 |
+
|
96 |
+
window[ gtm4wp_datalayer_name ].push({
|
97 |
+
'event': 'gtm4wp.socialAction',
|
98 |
+
'network': 'twitter',
|
99 |
+
'socialAction': 'follow',
|
100 |
+
'opt_target': label,
|
101 |
+
'opt_pagePath': window.location.href
|
102 |
+
});
|
103 |
+
}
|
104 |
+
});
|
105 |
+
});
|
106 |
+
}
|
107 |
+
});
|
js/gtm4wp-soundcloud.js
CHANGED
@@ -1,138 +1,137 @@
|
|
1 |
-
;
|
2 |
-
var
|
3 |
-
|
4 |
-
|
5 |
-
jQuery(function() {
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
jqframe.attr( "data-
|
17 |
-
jqframe.attr( "data-
|
18 |
-
jqframe.attr( "data-
|
19 |
-
jqframe.attr( "data-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
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 |
-
});
|
1 |
+
var gtm4wp_soundclound_percentage_tracking = 10;
|
2 |
+
var gtm4wp_soundclound_percentage_tracking_marks = {};
|
3 |
+
|
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 ) {
|
14 |
+
|
15 |
+
jqframe.attr( "data-player_id", soundData.id );
|
16 |
+
jqframe.attr( "data-player_author", soundData.user.username );
|
17 |
+
jqframe.attr( "data-player_title", soundData.title );
|
18 |
+
jqframe.attr( "data-player_url", soundData.permalink_url );
|
19 |
+
jqframe.attr( "data-player_duration", soundData.duration );
|
20 |
+
|
21 |
+
sound = soundData;
|
22 |
+
|
23 |
+
window[ gtm4wp_datalayer_name ].push({
|
24 |
+
'event': 'gtm4wp.mediaPlayerReady',
|
25 |
+
'mediaType': 'soundcloud',
|
26 |
+
'mediaData': {
|
27 |
+
'id': soundData.id,
|
28 |
+
'author': soundData.user.username,
|
29 |
+
'title': soundData.title,
|
30 |
+
'url': soundData.permalink_url,
|
31 |
+
'duration': soundData.duration
|
32 |
+
},
|
33 |
+
'mediaCurrentTime': 0
|
34 |
+
});
|
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 ) {
|
42 |
+
gtm4wp_onSoundCloudPlayerStateChange( eventData, 'play' );
|
43 |
+
});
|
44 |
+
|
45 |
+
widget.bind( SC.Widget.Events.PAUSE, function( eventData ) {
|
46 |
+
gtm4wp_onSoundCloudPlayerStateChange( eventData, 'pause' );
|
47 |
+
});
|
48 |
+
|
49 |
+
widget.bind( SC.Widget.Events.FINISH, function( eventData ) {
|
50 |
+
gtm4wp_onSoundCloudPlayerStateChange( eventData, 'ended' );
|
51 |
+
});
|
52 |
+
|
53 |
+
widget.bind( SC.Widget.Events.SEEK, function( eventData ) {
|
54 |
+
gtm4wp_onSoundCloudPlayerStateChange( eventData, 'seeked' );
|
55 |
+
});
|
56 |
+
|
57 |
+
widget.bind( SC.Widget.Events.CLICK_DOWNLOAD, function() {
|
58 |
+
gtm4wp_onSoundCloudPlayerEvent( 'click-download' );
|
59 |
+
});
|
60 |
+
|
61 |
+
widget.bind( SC.Widget.Events.CLICK_BUY, function() {
|
62 |
+
gtm4wp_onSoundCloudPlayerEvent( 'click-buy' );
|
63 |
+
});
|
64 |
+
|
65 |
+
widget.bind( SC.Widget.Events.OPEN_SHARE_PANEL, function() {
|
66 |
+
gtm4wp_onSoundCloudPlayerEvent( 'open-share-panel' );
|
67 |
+
});
|
68 |
+
|
69 |
+
widget.bind( SC.Widget.Events.ERROR, function() {
|
70 |
+
gtm4wp_onSoundCloudPlayerEvent( 'error' );
|
71 |
+
});
|
72 |
+
});
|
73 |
+
|
74 |
+
var gtm4wp_onSoundCloudPlayerStateChange = function( eventData, playerState ) {
|
75 |
+
window[ gtm4wp_datalayer_name ].push({
|
76 |
+
'event': 'gtm4wp.mediaPlayerStateChange',
|
77 |
+
'mediaType': 'soundcloud',
|
78 |
+
'mediaData': {
|
79 |
+
'id': sound.id,
|
80 |
+
'author': sound.user.username,
|
81 |
+
'title': sound.title,
|
82 |
+
'url': sound.permalink_url,
|
83 |
+
'duration': sound.duration
|
84 |
+
},
|
85 |
+
'mediaCurrentTime': eventData.currentPosition,
|
86 |
+
'mediaPlayerState': playerState
|
87 |
+
});
|
88 |
+
};
|
89 |
+
|
90 |
+
var gtm4wp_onSoundCloudPercentageChange = function( eventData ) {
|
91 |
+
var mediaPercentage = Math.floor( eventData.currentPosition / sound.duration * 100 );
|
92 |
+
|
93 |
+
if ( typeof gtm4wp_soundclound_percentage_tracking_marks[ sound.id ] == "undefined" ) {
|
94 |
+
gtm4wp_soundclound_percentage_tracking_marks[ sound.id ] = [];
|
95 |
+
}
|
96 |
+
|
97 |
+
for( var i=0; i<100; i+=gtm4wp_soundclound_percentage_tracking ) {
|
98 |
+
if ( ( mediaPercentage > i ) && ( gtm4wp_soundclound_percentage_tracking_marks[ sound.id ].indexOf( i ) == -1 ) ) {
|
99 |
+
gtm4wp_soundclound_percentage_tracking_marks[ sound.id ].push( i );
|
100 |
+
|
101 |
+
window[ gtm4wp_datalayer_name ].push({
|
102 |
+
'event': 'gtm4wp.mediaPlaybackPercentage',
|
103 |
+
'mediaType': 'soundcloud',
|
104 |
+
'mediaData': {
|
105 |
+
'id': sound.id,
|
106 |
+
'author': sound.user.username,
|
107 |
+
'title': sound.title,
|
108 |
+
'url': sound.permalink_url,
|
109 |
+
'duration': sound.duration
|
110 |
+
},
|
111 |
+
'mediaCurrentTime': eventData.currentPosition,
|
112 |
+
'mediaPercentage': i
|
113 |
+
});
|
114 |
+
}
|
115 |
+
}
|
116 |
+
};
|
117 |
+
|
118 |
+
var gtm4wp_onSoundCloudPlayerEvent = function( eventName ) {
|
119 |
+
widget.getPosition(function( currentPosition ) {
|
120 |
+
window[ gtm4wp_datalayer_name ].push({
|
121 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
122 |
+
'mediaType': 'soundcloud',
|
123 |
+
'mediaData': {
|
124 |
+
'id': sound.id,
|
125 |
+
'author': sound.user.username,
|
126 |
+
'title': sound.title,
|
127 |
+
'url': sound.permalink_url,
|
128 |
+
'duration': soundData.duration
|
129 |
+
},
|
130 |
+
'mediaCurrentTime': currentPosition,
|
131 |
+
'mediaPlayerEvent': eventName
|
132 |
+
});
|
133 |
+
});
|
134 |
+
};
|
135 |
+
|
136 |
+
});
|
137 |
+
});
|
|
js/gtm4wp-users.js
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function gtm4wp_set_cookie( cookiename, cookievalue, expiredays ) {
|
2 |
+
var d = new Date();
|
3 |
+
d.setTime(d.getTime() + (expiredays*24*60*60*1000));
|
4 |
+
var expires = "expires="+ d.toUTCString();
|
5 |
+
|
6 |
+
document.cookie = cookiename + "=" + cookievalue + ";" + expires + ";path=/";
|
7 |
+
}
|
8 |
+
|
9 |
+
function gtm4wp_get_cookie( cookiename ) {
|
10 |
+
var decoded_cookie_list = decodeURIComponent(document.cookie).split(';');
|
11 |
+
var onecookie = '';
|
12 |
+
|
13 |
+
for( var i=0; i<decoded_cookie_list.length; i++ ) {
|
14 |
+
onecookie = decoded_cookie_list[i].trim();
|
15 |
+
if ( 0 == onecookie.indexOf( cookiename ) ) {
|
16 |
+
return onecookie.substring( cookiename.length+1, onecookie.length );
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
return "";
|
21 |
+
}
|
22 |
+
|
23 |
+
var gtm4wp_user_logged_in = gtm4wp_get_cookie( 'gtm4wp_user_logged_in' );
|
24 |
+
if ( gtm4wp_user_logged_in === "1" ) {
|
25 |
+
window[ gtm4wp_datalayer_name ].push({
|
26 |
+
'event': 'gtm4wp.userLoggedIn',
|
27 |
+
});
|
28 |
+
|
29 |
+
gtm4wp_set_cookie( 'gtm4wp_user_logged_in', '', -1 );
|
30 |
+
}
|
31 |
+
|
32 |
+
var gtm4wp_new_user_registered = gtm4wp_get_cookie( 'gtm4wp_user_registered' );
|
33 |
+
if ( gtm4wp_new_user_registered === "1" ) {
|
34 |
+
window[ gtm4wp_datalayer_name ].push({
|
35 |
+
'event': 'gtm4wp.userRegistered',
|
36 |
+
});
|
37 |
+
|
38 |
+
gtm4wp_set_cookie( 'gtm4wp_user_registered', '', -1 );
|
39 |
+
}
|
js/gtm4wp-vimeo-froogaloop.js
CHANGED
@@ -1,105 +1,105 @@
|
|
1 |
-
var gtm4wp_vimeo_percentage_tracking = 10;
|
2 |
-
var gtm4wp_vimeo_percentage_tracking_marks = {};
|
3 |
-
|
4 |
-
|
5 |
-
jQuery( '[id^="vimeoplayer_"]' ).each(function() {
|
6 |
-
var vimeoapi = $f( this ),
|
7 |
-
|
8 |
-
|
9 |
-
.attr( "src" )
|
10 |
-
.split( "?" )
|
11 |
-
.shift(),
|
12 |
-
|
13 |
-
|
14 |
-
jqframe.attr( "data-player_id", videoid );
|
15 |
-
jqframe.attr( "data-player_url", videourl );
|
16 |
-
|
17 |
-
vimeoapi.addEvent( 'ready', function( player_id ) {
|
18 |
-
vimeoapi.api( 'getDuration', function( value, player_id ) {
|
19 |
-
|
20 |
-
jqframe.attr( "data-player_duration", value );
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
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 ) {
|
41 |
-
gtm4wp_onVimeoPlayerStateChange( 'play' );
|
42 |
-
});
|
43 |
-
|
44 |
-
vimeoapi.addEvent( 'pause', function( player_id ) {
|
45 |
-
gtm4wp_onVimeoPlayerStateChange( 'pause' );
|
46 |
-
});
|
47 |
-
|
48 |
-
vimeoapi.addEvent( 'finish', function( player_id ) {
|
49 |
-
gtm4wp_onVimeoPlayerStateChange( 'finish' );
|
50 |
-
});
|
51 |
-
|
52 |
-
vimeoapi.addEvent( 'seek', function( value, player_id ) {
|
53 |
-
gtm4wp_onVimeoPlayerStateChange( 'seek' );
|
54 |
-
});
|
55 |
-
|
56 |
-
var gtm4wp_onVimeoPlayerStateChange = function( player_state ) {
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
var gtm4wp_onVimeoPercentageChange = function( data ) {
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
gtm4wp_vimeo_percentage_tracking_marks[ videoid ].push( i );
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
});
|
104 |
-
});
|
105 |
-
});
|
1 |
+
var gtm4wp_vimeo_percentage_tracking = 10;
|
2 |
+
var gtm4wp_vimeo_percentage_tracking_marks = {};
|
3 |
+
|
4 |
+
jQuery(function() {
|
5 |
+
jQuery( '[id^="vimeoplayer_"]' ).each(function() {
|
6 |
+
var vimeoapi = $f( this ),
|
7 |
+
jqframe = jQuery( this ),
|
8 |
+
videourl = jqframe
|
9 |
+
.attr( "src" )
|
10 |
+
.split( "?" )
|
11 |
+
.shift(),
|
12 |
+
videoid = videourl.split( "/" ).pop();
|
13 |
+
|
14 |
+
jqframe.attr( "data-player_id", videoid );
|
15 |
+
jqframe.attr( "data-player_url", videourl );
|
16 |
+
|
17 |
+
vimeoapi.addEvent( 'ready', function( player_id ) {
|
18 |
+
vimeoapi.api( 'getDuration', function( value, player_id ) {
|
19 |
+
|
20 |
+
jqframe.attr( "data-player_duration", value );
|
21 |
+
|
22 |
+
window[ gtm4wp_datalayer_name ].push({
|
23 |
+
'event': 'gtm4wp.mediaPlayerReady',
|
24 |
+
'mediaType': 'vimeo',
|
25 |
+
'mediaData': {
|
26 |
+
'id': videoid,
|
27 |
+
'author': '',
|
28 |
+
'title': jqframe.attr( "title" ),
|
29 |
+
'url': videourl,
|
30 |
+
'duration': value
|
31 |
+
},
|
32 |
+
'mediaCurrentTime': 0
|
33 |
+
});
|
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 ) {
|
41 |
+
gtm4wp_onVimeoPlayerStateChange( 'play' );
|
42 |
+
});
|
43 |
+
|
44 |
+
vimeoapi.addEvent( 'pause', function( player_id ) {
|
45 |
+
gtm4wp_onVimeoPlayerStateChange( 'pause' );
|
46 |
+
});
|
47 |
+
|
48 |
+
vimeoapi.addEvent( 'finish', function( player_id ) {
|
49 |
+
gtm4wp_onVimeoPlayerStateChange( 'finish' );
|
50 |
+
});
|
51 |
+
|
52 |
+
vimeoapi.addEvent( 'seek', function( value, player_id ) {
|
53 |
+
gtm4wp_onVimeoPlayerStateChange( 'seek' );
|
54 |
+
});
|
55 |
+
|
56 |
+
var gtm4wp_onVimeoPlayerStateChange = function( player_state ) {
|
57 |
+
vimeoapi.api( 'getCurrentTime', function( value, player_id ) {
|
58 |
+
window[ gtm4wp_datalayer_name ].push({
|
59 |
+
'event': 'gtm4wp.mediaPlayerStateChange',
|
60 |
+
'mediaType': 'vimeo',
|
61 |
+
'mediaData': {
|
62 |
+
'id': videoid,
|
63 |
+
'author': '',
|
64 |
+
'title': jqframe.attr( "title" ),
|
65 |
+
'url': jqframe.attr( "data-player_url" ),
|
66 |
+
'duration': parseInt( jqframe.attr( "data-player_duration" ) )
|
67 |
+
},
|
68 |
+
'mediaPlayerState': player_state,
|
69 |
+
'mediaCurrentTime': value
|
70 |
+
});
|
71 |
+
});
|
72 |
+
};
|
73 |
+
|
74 |
+
var gtm4wp_onVimeoPercentageChange = function( data ) {
|
75 |
+
var videoDuration = parseInt( jqframe.attr( "data-player_duration" ) );
|
76 |
+
var videoPercentage = Math.floor( data.seconds / videoDuration * 100 );
|
77 |
+
|
78 |
+
if ( typeof gtm4wp_vimeo_percentage_tracking_marks[ videoid ] == "undefined" ) {
|
79 |
+
gtm4wp_vimeo_percentage_tracking_marks[ videoid ] = [];
|
80 |
+
}
|
81 |
+
|
82 |
+
for( var i=0; i<100; i+=gtm4wp_vimeo_percentage_tracking ) {
|
83 |
+
if ( ( videoPercentage > i ) && ( gtm4wp_vimeo_percentage_tracking_marks[ videoid ].indexOf( i ) == -1 ) ) {
|
84 |
+
gtm4wp_vimeo_percentage_tracking_marks[ videoid ].push( i );
|
85 |
+
|
86 |
+
window[ gtm4wp_datalayer_name ].push({
|
87 |
+
'event': 'gtm4wp.mediaPlaybackPercentage',
|
88 |
+
'mediaType': 'vimeo',
|
89 |
+
'mediaData': {
|
90 |
+
'id': videoid,
|
91 |
+
'author': '',
|
92 |
+
'title': jqframe.attr( "title" ),
|
93 |
+
'url': jqframe.attr( "data-player_url" ),
|
94 |
+
'duration': videoDuration
|
95 |
+
},
|
96 |
+
'mediaCurrentTime': data.seconds,
|
97 |
+
'mediaPercentage': i
|
98 |
+
});
|
99 |
+
}
|
100 |
+
}
|
101 |
+
};
|
102 |
+
|
103 |
+
});
|
104 |
+
});
|
105 |
+
});
|
js/gtm4wp-vimeo.js
CHANGED
@@ -1,268 +1,268 @@
|
|
1 |
-
var gtm4wp_vimeo_percentage_tracking = 10;
|
2 |
-
var gtm4wp_vimeo_percentage_tracking_marks = {};
|
3 |
-
|
4 |
-
|
5 |
-
jQuery( 'iframe[src*="vimeo.com"]' ).each(function() {
|
6 |
-
var vimeoapi = new Vimeo.Player( this ),
|
7 |
-
|
8 |
-
|
9 |
-
.attr( "src" )
|
10 |
-
.split( "?" )
|
11 |
-
.shift(),
|
12 |
-
|
13 |
-
|
14 |
-
jqframe.attr( "data-player_id", videoid );
|
15 |
-
jqframe.attr( "data-player_url", videourl );
|
16 |
-
|
17 |
-
vimeoapi.getVideoTitle().then( function( title ) {
|
18 |
-
jqframe.attr( "data-player_title", title );
|
19 |
-
|
20 |
-
vimeoapi.getDuration().then( function( duration ) {
|
21 |
-
|
22 |
-
jqframe.attr( "data-player_duration", duration );
|
23 |
-
|
24 |
-
window[ gtm4wp_datalayer_name ].push({
|
25 |
-
'event': 'gtm4wp.mediaPlayerReady',
|
26 |
-
'mediaType': 'vimeo',
|
27 |
-
'mediaData': {
|
28 |
-
'id': videoid,
|
29 |
-
'author': '',
|
30 |
-
'title': jqframe.attr( "data-player_title" ),
|
31 |
-
'url': videourl,
|
32 |
-
'duration': duration
|
33 |
-
},
|
34 |
-
'mediaCurrentTime': 0
|
35 |
-
});
|
36 |
-
|
37 |
-
}).catch( function( error ) {
|
38 |
-
|
39 |
-
window[ gtm4wp_datalayer_name ].push({
|
40 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
41 |
-
'mediaType': 'vimeo',
|
42 |
-
'mediaData': {
|
43 |
-
'id': videoid,
|
44 |
-
'author': '',
|
45 |
-
'title': jqframe.attr( "data-player_title" ),
|
46 |
-
'url': videourl,
|
47 |
-
'duration': 0
|
48 |
-
},
|
49 |
-
'mediaCurrentTime': 0,
|
50 |
-
'mediaPlayerEvent': 'error',
|
51 |
-
'mediaPlayerEventParam': error
|
52 |
-
});
|
53 |
-
|
54 |
-
}); // end of api call getDuration
|
55 |
-
|
56 |
-
}).catch( function( error ) {
|
57 |
-
|
58 |
-
window[ gtm4wp_datalayer_name ].push({
|
59 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
60 |
-
'mediaType': 'vimeo',
|
61 |
-
'mediaData': {
|
62 |
-
'id': videoid,
|
63 |
-
'author': '',
|
64 |
-
'title': "Unknown title",
|
65 |
-
'url': videourl,
|
66 |
-
'duration': 0
|
67 |
-
},
|
68 |
-
'mediaCurrentTime': 0,
|
69 |
-
'mediaPlayerEvent': 'error',
|
70 |
-
'mediaPlayerEventParam': error
|
71 |
-
});
|
72 |
-
|
73 |
-
}); // end of api call getVideoTitle
|
74 |
-
|
75 |
-
vimeoapi.on( 'play', function( data ) {
|
76 |
-
gtm4wp_onVimeoPlayerStateChange( 'play', data );
|
77 |
-
});
|
78 |
-
|
79 |
-
vimeoapi.on( 'pause', function( data ) {
|
80 |
-
gtm4wp_onVimeoPlayerStateChange( 'pause', data );
|
81 |
-
});
|
82 |
-
|
83 |
-
vimeoapi.on( 'ended', function( data ) {
|
84 |
-
gtm4wp_onVimeoPlayerStateChange( 'ended', data );
|
85 |
-
});
|
86 |
-
|
87 |
-
vimeoapi.on( 'seeked', function( data ) {
|
88 |
-
gtm4wp_onVimeoPlayerStateChange( 'seeked', data );
|
89 |
-
});
|
90 |
-
|
91 |
-
vimeoapi.on( 'texttrackchange', function( data ) {
|
92 |
-
|
93 |
-
vimeoapi.getCurrentTime().then( function( seconds ) {
|
94 |
-
|
95 |
-
window[ gtm4wp_datalayer_name ].push({
|
96 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
97 |
-
'mediaType': 'vimeo',
|
98 |
-
'mediaData': {
|
99 |
-
'id': videoid,
|
100 |
-
'author': '',
|
101 |
-
'title': jqframe.attr( "data-player_title" ),
|
102 |
-
'url': jqframe.attr( "data-player_url" ),
|
103 |
-
'duration': jqframe.attr( "data-player_duration" )
|
104 |
-
},
|
105 |
-
'mediaPlayerEvent': 'texttrackchange',
|
106 |
-
'mediaPlayerEventParam': data,
|
107 |
-
'mediaCurrentTime': seconds
|
108 |
-
|
109 |
-
}).catch( function( error ) {
|
110 |
-
|
111 |
-
window[ gtm4wp_datalayer_name ].push({
|
112 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
113 |
-
'mediaType': 'vimeo',
|
114 |
-
'mediaData': {
|
115 |
-
'id': videoid,
|
116 |
-
'author': '',
|
117 |
-
'title': "Unknown title",
|
118 |
-
'url': videourl,
|
119 |
-
'duration': jqframe.attr( "data-player_duration" )
|
120 |
-
},
|
121 |
-
'mediaCurrentTime': 0,
|
122 |
-
'mediaPlayerEvent': 'error',
|
123 |
-
'mediaPlayerEventParam': error
|
124 |
-
});
|
125 |
-
|
126 |
-
}); // end call api getCurrentTime()
|
127 |
-
|
128 |
-
});
|
129 |
-
|
130 |
-
});
|
131 |
-
|
132 |
-
vimeoapi.on( 'volumechange', function( data ) {
|
133 |
-
|
134 |
-
vimeoapi.getCurrentTime().then( function( seconds ) {
|
135 |
-
|
136 |
-
window[ gtm4wp_datalayer_name ].push({
|
137 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
138 |
-
'mediaType': 'vimeo',
|
139 |
-
'mediaData': {
|
140 |
-
'id': videoid,
|
141 |
-
'author': '',
|
142 |
-
'title': jqframe.attr( "data-player_title" ),
|
143 |
-
'url': jqframe.attr( "data-player_url" ),
|
144 |
-
'duration': jqframe.attr( "data-player_duration" )
|
145 |
-
},
|
146 |
-
'mediaPlayerEvent': 'volumechange',
|
147 |
-
'mediaPlayerEventParam': data.volume,
|
148 |
-
'mediaCurrentTime': seconds
|
149 |
-
|
150 |
-
}).catch( function( error ) {
|
151 |
-
|
152 |
-
window[ gtm4wp_datalayer_name ].push({
|
153 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
154 |
-
'mediaType': 'vimeo',
|
155 |
-
'mediaData': {
|
156 |
-
'id': videoid,
|
157 |
-
'author': '',
|
158 |
-
'title': "Unknown title",
|
159 |
-
'url': videourl,
|
160 |
-
'duration': jqframe.attr( "data-player_duration" )
|
161 |
-
},
|
162 |
-
'mediaCurrentTime': 0,
|
163 |
-
'mediaPlayerEvent': 'error',
|
164 |
-
'mediaPlayerEventParam': error
|
165 |
-
});
|
166 |
-
|
167 |
-
}); // end call api getCurrentTime()
|
168 |
-
|
169 |
-
});
|
170 |
-
|
171 |
-
});
|
172 |
-
|
173 |
-
vimeoapi.on( 'error', function( data ) {
|
174 |
-
|
175 |
-
vimeoapi.getCurrentTime().then( function( seconds ) {
|
176 |
-
|
177 |
-
window[ gtm4wp_datalayer_name ].push({
|
178 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
179 |
-
'mediaType': 'vimeo',
|
180 |
-
'mediaData': {
|
181 |
-
'id': videoid,
|
182 |
-
'author': '',
|
183 |
-
'title': jqframe.attr( "data-player_title" ),
|
184 |
-
'url': jqframe.attr( "data-player_url" ),
|
185 |
-
'duration': jqframe.attr( "data-player_duration" )
|
186 |
-
},
|
187 |
-
'mediaPlayerEvent': 'error',
|
188 |
-
'mediaPlayerEventParam': data,
|
189 |
-
'mediaCurrentTime': seconds
|
190 |
-
|
191 |
-
}).catch( function( error ) {
|
192 |
-
|
193 |
-
window[ gtm4wp_datalayer_name ].push({
|
194 |
-
'event': 'gtm4wp.mediaPlayerEvent',
|
195 |
-
'mediaType': 'vimeo',
|
196 |
-
'mediaData': {
|
197 |
-
'id': videoid,
|
198 |
-
'author': '',
|
199 |
-
'title': "Unknown title",
|
200 |
-
'url': videourl,
|
201 |
-
'duration': jqframe.attr( "data-player_duration" )
|
202 |
-
},
|
203 |
-
'mediaCurrentTime': 0,
|
204 |
-
'mediaPlayerEvent': 'error',
|
205 |
-
'mediaPlayerEventParam': error
|
206 |
-
});
|
207 |
-
|
208 |
-
}); // end call api getCurrentTime()
|
209 |
-
|
210 |
-
});
|
211 |
-
});
|
212 |
-
|
213 |
-
vimeoapi.on( 'timeupdate', function( data ) {
|
214 |
-
gtm4wp_onVimeoPercentageChange( data );
|
215 |
-
});
|
216 |
-
|
217 |
-
var gtm4wp_onVimeoPlayerStateChange = function( player_state, data ) {
|
218 |
-
|
219 |
-
window[ gtm4wp_datalayer_name ].push({
|
220 |
-
'event': 'gtm4wp.mediaPlayerStateChange',
|
221 |
-
'mediaType': 'vimeo',
|
222 |
-
'mediaData': {
|
223 |
-
'id': videoid,
|
224 |
-
'author': '',
|
225 |
-
'title': jqframe.attr( "data-player_title" ),
|
226 |
-
'url': jqframe.attr( "data-player_url" ),
|
227 |
-
'duration': data.duration
|
228 |
-
},
|
229 |
-
'mediaPlayerState': player_state,
|
230 |
-
'mediaCurrentTime': data.seconds
|
231 |
-
});
|
232 |
-
|
233 |
-
}
|
234 |
-
|
235 |
-
var gtm4wp_onVimeoPercentageChange = function( data ) {
|
236 |
-
|
237 |
-
var videoDuration = data.duration;
|
238 |
-
var videoPercentage = Math.floor( data.seconds / videoDuration * 100 );
|
239 |
-
|
240 |
-
if ( typeof gtm4wp_vimeo_percentage_tracking_marks[ videoid ] == "undefined" ) {
|
241 |
-
gtm4wp_vimeo_percentage_tracking_marks[ videoid ] = [];
|
242 |
-
}
|
243 |
-
|
244 |
-
for( var i=0; i<100; i+=gtm4wp_vimeo_percentage_tracking ) {
|
245 |
-
if ( ( videoPercentage > i ) && ( gtm4wp_vimeo_percentage_tracking_marks[ videoid ].indexOf( i ) == -1 ) ) {
|
246 |
-
|
247 |
-
gtm4wp_vimeo_percentage_tracking_marks[ videoid ].push( i );
|
248 |
-
|
249 |
-
window[ gtm4wp_datalayer_name ].push({
|
250 |
-
'event': 'gtm4wp.mediaPlaybackPercentage',
|
251 |
-
'mediaType': 'vimeo',
|
252 |
-
'mediaData': {
|
253 |
-
'id': videoid,
|
254 |
-
'author': '',
|
255 |
-
'title': jqframe.attr( "data-player_title" ),
|
256 |
-
'url': jqframe.attr( "data-player_url" ),
|
257 |
-
'duration': videoDuration
|
258 |
-
},
|
259 |
-
'mediaCurrentTime': data.seconds,
|
260 |
-
'mediaPercentage': i
|
261 |
-
});
|
262 |
-
|
263 |
-
}
|
264 |
-
}
|
265 |
-
}
|
266 |
-
|
267 |
-
});
|
268 |
-
});
|
1 |
+
var gtm4wp_vimeo_percentage_tracking = 10;
|
2 |
+
var gtm4wp_vimeo_percentage_tracking_marks = {};
|
3 |
+
|
4 |
+
jQuery(function() {
|
5 |
+
jQuery( 'iframe[src*="vimeo.com"]' ).each(function() {
|
6 |
+
var vimeoapi = new Vimeo.Player( this ),
|
7 |
+
jqframe = jQuery( this ),
|
8 |
+
videourl = jqframe
|
9 |
+
.attr( "src" )
|
10 |
+
.split( "?" )
|
11 |
+
.shift(),
|
12 |
+
videoid = videourl.split( "/" ).pop();
|
13 |
+
|
14 |
+
jqframe.attr( "data-player_id", videoid );
|
15 |
+
jqframe.attr( "data-player_url", videourl );
|
16 |
+
|
17 |
+
vimeoapi.getVideoTitle().then( function( title ) {
|
18 |
+
jqframe.attr( "data-player_title", title );
|
19 |
+
|
20 |
+
vimeoapi.getDuration().then( function( duration ) {
|
21 |
+
|
22 |
+
jqframe.attr( "data-player_duration", duration );
|
23 |
+
|
24 |
+
window[ gtm4wp_datalayer_name ].push({
|
25 |
+
'event': 'gtm4wp.mediaPlayerReady',
|
26 |
+
'mediaType': 'vimeo',
|
27 |
+
'mediaData': {
|
28 |
+
'id': videoid,
|
29 |
+
'author': '',
|
30 |
+
'title': jqframe.attr( "data-player_title" ),
|
31 |
+
'url': videourl,
|
32 |
+
'duration': duration
|
33 |
+
},
|
34 |
+
'mediaCurrentTime': 0
|
35 |
+
});
|
36 |
+
|
37 |
+
}).catch( function( error ) {
|
38 |
+
|
39 |
+
window[ gtm4wp_datalayer_name ].push({
|
40 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
41 |
+
'mediaType': 'vimeo',
|
42 |
+
'mediaData': {
|
43 |
+
'id': videoid,
|
44 |
+
'author': '',
|
45 |
+
'title': jqframe.attr( "data-player_title" ),
|
46 |
+
'url': videourl,
|
47 |
+
'duration': 0
|
48 |
+
},
|
49 |
+
'mediaCurrentTime': 0,
|
50 |
+
'mediaPlayerEvent': 'error',
|
51 |
+
'mediaPlayerEventParam': error
|
52 |
+
});
|
53 |
+
|
54 |
+
}); // end of api call getDuration
|
55 |
+
|
56 |
+
}).catch( function( error ) {
|
57 |
+
|
58 |
+
window[ gtm4wp_datalayer_name ].push({
|
59 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
60 |
+
'mediaType': 'vimeo',
|
61 |
+
'mediaData': {
|
62 |
+
'id': videoid,
|
63 |
+
'author': '',
|
64 |
+
'title': "Unknown title",
|
65 |
+
'url': videourl,
|
66 |
+
'duration': 0
|
67 |
+
},
|
68 |
+
'mediaCurrentTime': 0,
|
69 |
+
'mediaPlayerEvent': 'error',
|
70 |
+
'mediaPlayerEventParam': error
|
71 |
+
});
|
72 |
+
|
73 |
+
}); // end of api call getVideoTitle
|
74 |
+
|
75 |
+
vimeoapi.on( 'play', function( data ) {
|
76 |
+
gtm4wp_onVimeoPlayerStateChange( 'play', data );
|
77 |
+
});
|
78 |
+
|
79 |
+
vimeoapi.on( 'pause', function( data ) {
|
80 |
+
gtm4wp_onVimeoPlayerStateChange( 'pause', data );
|
81 |
+
});
|
82 |
+
|
83 |
+
vimeoapi.on( 'ended', function( data ) {
|
84 |
+
gtm4wp_onVimeoPlayerStateChange( 'ended', data );
|
85 |
+
});
|
86 |
+
|
87 |
+
vimeoapi.on( 'seeked', function( data ) {
|
88 |
+
gtm4wp_onVimeoPlayerStateChange( 'seeked', data );
|
89 |
+
});
|
90 |
+
|
91 |
+
vimeoapi.on( 'texttrackchange', function( data ) {
|
92 |
+
|
93 |
+
vimeoapi.getCurrentTime().then( function( seconds ) {
|
94 |
+
|
95 |
+
window[ gtm4wp_datalayer_name ].push({
|
96 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
97 |
+
'mediaType': 'vimeo',
|
98 |
+
'mediaData': {
|
99 |
+
'id': videoid,
|
100 |
+
'author': '',
|
101 |
+
'title': jqframe.attr( "data-player_title" ),
|
102 |
+
'url': jqframe.attr( "data-player_url" ),
|
103 |
+
'duration': jqframe.attr( "data-player_duration" )
|
104 |
+
},
|
105 |
+
'mediaPlayerEvent': 'texttrackchange',
|
106 |
+
'mediaPlayerEventParam': data,
|
107 |
+
'mediaCurrentTime': seconds
|
108 |
+
|
109 |
+
}).catch( function( error ) {
|
110 |
+
|
111 |
+
window[ gtm4wp_datalayer_name ].push({
|
112 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
113 |
+
'mediaType': 'vimeo',
|
114 |
+
'mediaData': {
|
115 |
+
'id': videoid,
|
116 |
+
'author': '',
|
117 |
+
'title': "Unknown title",
|
118 |
+
'url': videourl,
|
119 |
+
'duration': jqframe.attr( "data-player_duration" )
|
120 |
+
},
|
121 |
+
'mediaCurrentTime': 0,
|
122 |
+
'mediaPlayerEvent': 'error',
|
123 |
+
'mediaPlayerEventParam': error
|
124 |
+
});
|
125 |
+
|
126 |
+
}); // end call api getCurrentTime()
|
127 |
+
|
128 |
+
});
|
129 |
+
|
130 |
+
});
|
131 |
+
|
132 |
+
vimeoapi.on( 'volumechange', function( data ) {
|
133 |
+
|
134 |
+
vimeoapi.getCurrentTime().then( function( seconds ) {
|
135 |
+
|
136 |
+
window[ gtm4wp_datalayer_name ].push({
|
137 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
138 |
+
'mediaType': 'vimeo',
|
139 |
+
'mediaData': {
|
140 |
+
'id': videoid,
|
141 |
+
'author': '',
|
142 |
+
'title': jqframe.attr( "data-player_title" ),
|
143 |
+
'url': jqframe.attr( "data-player_url" ),
|
144 |
+
'duration': jqframe.attr( "data-player_duration" )
|
145 |
+
},
|
146 |
+
'mediaPlayerEvent': 'volumechange',
|
147 |
+
'mediaPlayerEventParam': data.volume,
|
148 |
+
'mediaCurrentTime': seconds
|
149 |
+
|
150 |
+
}).catch( function( error ) {
|
151 |
+
|
152 |
+
window[ gtm4wp_datalayer_name ].push({
|
153 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
154 |
+
'mediaType': 'vimeo',
|
155 |
+
'mediaData': {
|
156 |
+
'id': videoid,
|
157 |
+
'author': '',
|
158 |
+
'title': "Unknown title",
|
159 |
+
'url': videourl,
|
160 |
+
'duration': jqframe.attr( "data-player_duration" )
|
161 |
+
},
|
162 |
+
'mediaCurrentTime': 0,
|
163 |
+
'mediaPlayerEvent': 'error',
|
164 |
+
'mediaPlayerEventParam': error
|
165 |
+
});
|
166 |
+
|
167 |
+
}); // end call api getCurrentTime()
|
168 |
+
|
169 |
+
});
|
170 |
+
|
171 |
+
});
|
172 |
+
|
173 |
+
vimeoapi.on( 'error', function( data ) {
|
174 |
+
|
175 |
+
vimeoapi.getCurrentTime().then( function( seconds ) {
|
176 |
+
|
177 |
+
window[ gtm4wp_datalayer_name ].push({
|
178 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
179 |
+
'mediaType': 'vimeo',
|
180 |
+
'mediaData': {
|
181 |
+
'id': videoid,
|
182 |
+
'author': '',
|
183 |
+
'title': jqframe.attr( "data-player_title" ),
|
184 |
+
'url': jqframe.attr( "data-player_url" ),
|
185 |
+
'duration': jqframe.attr( "data-player_duration" )
|
186 |
+
},
|
187 |
+
'mediaPlayerEvent': 'error',
|
188 |
+
'mediaPlayerEventParam': data,
|
189 |
+
'mediaCurrentTime': seconds
|
190 |
+
|
191 |
+
}).catch( function( error ) {
|
192 |
+
|
193 |
+
window[ gtm4wp_datalayer_name ].push({
|
194 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
195 |
+
'mediaType': 'vimeo',
|
196 |
+
'mediaData': {
|
197 |
+
'id': videoid,
|
198 |
+
'author': '',
|
199 |
+
'title': "Unknown title",
|
200 |
+
'url': videourl,
|
201 |
+
'duration': jqframe.attr( "data-player_duration" )
|
202 |
+
},
|
203 |
+
'mediaCurrentTime': 0,
|
204 |
+
'mediaPlayerEvent': 'error',
|
205 |
+
'mediaPlayerEventParam': error
|
206 |
+
});
|
207 |
+
|
208 |
+
}); // end call api getCurrentTime()
|
209 |
+
|
210 |
+
});
|
211 |
+
});
|
212 |
+
|
213 |
+
vimeoapi.on( 'timeupdate', function( data ) {
|
214 |
+
gtm4wp_onVimeoPercentageChange( data );
|
215 |
+
});
|
216 |
+
|
217 |
+
var gtm4wp_onVimeoPlayerStateChange = function( player_state, data ) {
|
218 |
+
|
219 |
+
window[ gtm4wp_datalayer_name ].push({
|
220 |
+
'event': 'gtm4wp.mediaPlayerStateChange',
|
221 |
+
'mediaType': 'vimeo',
|
222 |
+
'mediaData': {
|
223 |
+
'id': videoid,
|
224 |
+
'author': '',
|
225 |
+
'title': jqframe.attr( "data-player_title" ),
|
226 |
+
'url': jqframe.attr( "data-player_url" ),
|
227 |
+
'duration': data.duration
|
228 |
+
},
|
229 |
+
'mediaPlayerState': player_state,
|
230 |
+
'mediaCurrentTime': data.seconds
|
231 |
+
});
|
232 |
+
|
233 |
+
};
|
234 |
+
|
235 |
+
var gtm4wp_onVimeoPercentageChange = function( data ) {
|
236 |
+
|
237 |
+
var videoDuration = data.duration;
|
238 |
+
var videoPercentage = Math.floor( data.seconds / videoDuration * 100 );
|
239 |
+
|
240 |
+
if ( typeof gtm4wp_vimeo_percentage_tracking_marks[ videoid ] == "undefined" ) {
|
241 |
+
gtm4wp_vimeo_percentage_tracking_marks[ videoid ] = [];
|
242 |
+
}
|
243 |
+
|
244 |
+
for( var i=0; i<100; i+=gtm4wp_vimeo_percentage_tracking ) {
|
245 |
+
if ( ( videoPercentage > i ) && ( gtm4wp_vimeo_percentage_tracking_marks[ videoid ].indexOf( i ) == -1 ) ) {
|
246 |
+
|
247 |
+
gtm4wp_vimeo_percentage_tracking_marks[ videoid ].push( i );
|
248 |
+
|
249 |
+
window[ gtm4wp_datalayer_name ].push({
|
250 |
+
'event': 'gtm4wp.mediaPlaybackPercentage',
|
251 |
+
'mediaType': 'vimeo',
|
252 |
+
'mediaData': {
|
253 |
+
'id': videoid,
|
254 |
+
'author': '',
|
255 |
+
'title': jqframe.attr( "data-player_title" ),
|
256 |
+
'url': jqframe.attr( "data-player_url" ),
|
257 |
+
'duration': videoDuration
|
258 |
+
},
|
259 |
+
'mediaCurrentTime': data.seconds,
|
260 |
+
'mediaPercentage': i
|
261 |
+
});
|
262 |
+
|
263 |
+
}
|
264 |
+
}
|
265 |
+
};
|
266 |
+
|
267 |
+
});
|
268 |
+
});
|
js/gtm4wp-woocommerce-classic.js
CHANGED
@@ -1,15 +1,26 @@
|
|
1 |
-
|
2 |
-
jQuery( document ).on( 'click', '.single_add_to_cart_button', function() {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
'
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function() {
|
2 |
+
jQuery( document ).on( 'click', '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)', function() {
|
3 |
+
var productdata = jQuery( this ).closest( '.product' ).find( '.gtm4wp_productdata' );
|
4 |
+
|
5 |
+
window[ gtm4wp_datalayer_name ].push({
|
6 |
+
'event': 'gtm4wp.addProductToCart',
|
7 |
+
'productName': productdata.data( 'gtm4wp_product_name' ),
|
8 |
+
'productSKU': jQuery( this ).data( 'product_sku' ),
|
9 |
+
'productID': jQuery( this ).data( 'product_id' ),
|
10 |
+
});
|
11 |
+
});
|
12 |
+
|
13 |
+
jQuery( document ).on( 'click', '.single_add_to_cart_button', function() {
|
14 |
+
var _product_form = jQuery( this ).closest( 'form.cart' );
|
15 |
+
var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val();
|
16 |
+
var _product_name = jQuery( '[name=gtm4wp_name]', _product_form ).val();
|
17 |
+
var _product_sku = jQuery( '[name=gtm4wp_sku]', _product_form ).val();
|
18 |
+
|
19 |
+
window[ gtm4wp_datalayer_name ].push({
|
20 |
+
'event': 'gtm4wp.addProductToCart',
|
21 |
+
'productName': _product_name,
|
22 |
+
'productSKU': _product_sku,
|
23 |
+
'productID': _product_id
|
24 |
+
});
|
25 |
+
});
|
26 |
+
});
|
js/gtm4wp-woocommerce-enhanced.js
CHANGED
@@ -1,126 +1,570 @@
|
|
1 |
-
;
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var gtm4wp_last_selected_product_variation;
|
2 |
+
|
3 |
+
function gtm4wp_handle_cart_qty_change() {
|
4 |
+
jQuery( '.product-quantity input.qty' ).each(function() {
|
5 |
+
var _original_value = jQuery( this ).prop( 'defaultValue' );
|
6 |
+
|
7 |
+
var _current_value = parseInt( jQuery( this ).val() );
|
8 |
+
if ( Number.isNaN( _current_value ) ) {
|
9 |
+
_current_value = _original_value;
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( _original_value != _current_value ) {
|
13 |
+
var productdata = jQuery( this ).closest( '.cart_item' ).find( '.remove' );
|
14 |
+
|
15 |
+
if ( _original_value < _current_value ) {
|
16 |
+
window[ gtm4wp_datalayer_name ].push({
|
17 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
18 |
+
'ecommerce': {
|
19 |
+
'currencyCode': gtm4wp_currency,
|
20 |
+
'add': {
|
21 |
+
'products': [{
|
22 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
23 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
24 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
25 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
26 |
+
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
27 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
28 |
+
'quantity': _current_value - _original_value
|
29 |
+
}]
|
30 |
+
}
|
31 |
+
}
|
32 |
+
});
|
33 |
+
} else {
|
34 |
+
window[ gtm4wp_datalayer_name ].push({
|
35 |
+
'event': 'gtm4wp.removeFromCartEEC',
|
36 |
+
'ecommerce': {
|
37 |
+
'currencyCode': gtm4wp_currency,
|
38 |
+
'remove': {
|
39 |
+
'products': [{
|
40 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
41 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
42 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
43 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
44 |
+
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
45 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
46 |
+
'quantity': _original_value - _current_value
|
47 |
+
}]
|
48 |
+
}
|
49 |
+
}
|
50 |
+
});
|
51 |
+
}
|
52 |
+
} // end if qty changed
|
53 |
+
}); // end each qty field
|
54 |
+
} // end gtm4wp_handle_cart_qty_change()
|
55 |
+
|
56 |
+
jQuery(function() {
|
57 |
+
var is_cart = jQuery( 'body' ).hasClass( 'woocommerce-cart' );
|
58 |
+
var is_checkout = jQuery( 'body' ).hasClass( 'woocommerce-checkout' );
|
59 |
+
|
60 |
+
// track impressions of products in product lists
|
61 |
+
if ( jQuery( '.gtm4wp_productdata,.widget-product-item' ).length > 0 ) {
|
62 |
+
var products = [];
|
63 |
+
var productdata;
|
64 |
+
jQuery( '.gtm4wp_productdata,.widget-product-item' ).each( function() {
|
65 |
+
|
66 |
+
productdata = jQuery( this );
|
67 |
+
products.push({
|
68 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
69 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
70 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
71 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
72 |
+
'position': productdata.data( 'gtm4wp_product_listposition' ),
|
73 |
+
'list': productdata.data( 'gtm4wp_productlist_name' ),
|
74 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' )
|
75 |
+
});
|
76 |
+
|
77 |
+
});
|
78 |
+
|
79 |
+
if ( gtm4wp_product_per_impression > 0 ) {
|
80 |
+
// Need to split the product submissions up into chunks in order to avoid the GA 8kb submission limit
|
81 |
+
var chunk;
|
82 |
+
while ( products.length ) {
|
83 |
+
chunk = products.splice( 0, gtm4wp_product_per_impression );
|
84 |
+
|
85 |
+
window[ gtm4wp_datalayer_name ].push({
|
86 |
+
'event': 'gtm4wp.productImpressionEEC',
|
87 |
+
'ecommerce': {
|
88 |
+
'currencyCode': gtm4wp_currency,
|
89 |
+
'impressions': chunk
|
90 |
+
}
|
91 |
+
});
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
for( var i=0; i<window[ gtm4wp_datalayer_name ].length; i++ ) {
|
95 |
+
if ( window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ] ) {
|
96 |
+
|
97 |
+
if ( ! window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] ) {
|
98 |
+
window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] = [];
|
99 |
+
}
|
100 |
+
|
101 |
+
break;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
if ( i == window[ gtm4wp_datalayer_name ].length ) {
|
106 |
+
// no existing ecommerce data found in the datalayer
|
107 |
+
i = 0;
|
108 |
+
window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ] = {};
|
109 |
+
window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] = products;
|
110 |
+
}
|
111 |
+
|
112 |
+
window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'currencyCode' ] = gtm4wp_currency;
|
113 |
+
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
// track add to cart events for simple products in product lists
|
118 |
+
jQuery( document ).on( 'click', '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)', function() {
|
119 |
+
var productdata = jQuery( this ).closest( '.product' ).find( '.gtm4wp_productdata' );
|
120 |
+
|
121 |
+
window[ gtm4wp_datalayer_name ].push({
|
122 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
123 |
+
'ecommerce': {
|
124 |
+
'currencyCode': gtm4wp_currency,
|
125 |
+
'add': {
|
126 |
+
'products': [{
|
127 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
128 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
129 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
130 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
131 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
132 |
+
'quantity': 1
|
133 |
+
}]
|
134 |
+
}
|
135 |
+
}
|
136 |
+
});
|
137 |
+
});
|
138 |
+
|
139 |
+
// track add to cart events for products on product detail pages
|
140 |
+
jQuery( document ).on( 'click', '.single_add_to_cart_button', function() {
|
141 |
+
var _product_form = jQuery( this ).closest( 'form.cart' );
|
142 |
+
var _product_var_id = jQuery( '[name=variation_id]', _product_form );
|
143 |
+
var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val();
|
144 |
+
var _product_name = jQuery( '[name=gtm4wp_name]', _product_form ).val();
|
145 |
+
var _product_sku = jQuery( '[name=gtm4wp_sku]', _product_form ).val();
|
146 |
+
var _product_category = jQuery( '[name=gtm4wp_category]', _product_form ).val();
|
147 |
+
var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val();
|
148 |
+
var _product_currency = jQuery( '[name=gtm4wp_currency]', _product_form ).val();
|
149 |
+
var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val();
|
150 |
+
|
151 |
+
if ( _product_var_id.length > 0 ) {
|
152 |
+
if ( gtm4wp_last_selected_product_variation ) {
|
153 |
+
window[ gtm4wp_datalayer_name ].push({
|
154 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
155 |
+
'ecommerce': {
|
156 |
+
'currencyCode': _product_currency,
|
157 |
+
'add': {
|
158 |
+
'products': [gtm4wp_last_selected_product_variation]
|
159 |
+
}
|
160 |
+
}
|
161 |
+
});
|
162 |
+
}
|
163 |
+
/*
|
164 |
+
_product_var_id_val = _product_var_id.val();
|
165 |
+
_product_form_variations = _product_form.data( 'product_variations' );
|
166 |
+
|
167 |
+
_product_form_variations.forEach( function( product_var ) {
|
168 |
+
if ( product_var.variation_id == _product_var_id_val ) {
|
169 |
+
_product_var_sku = product_var.sku;
|
170 |
+
if ( ! _product_var_sku ) {
|
171 |
+
_product_var_sku = _product_var_id_val;
|
172 |
+
}
|
173 |
+
|
174 |
+
var _tmp = [];
|
175 |
+
for( var attrib_key in product_var.attributes ) {
|
176 |
+
_tmp.push( product_var.attributes[ attrib_key ] );
|
177 |
+
}
|
178 |
+
|
179 |
+
window[ gtm4wp_datalayer_name ].push({
|
180 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
181 |
+
'ecommerce': {
|
182 |
+
'currencyCode': _product_currency,
|
183 |
+
'add': {
|
184 |
+
'products': [{
|
185 |
+
'id': gtm4wp_use_sku_instead ? _product_var_sku : _product_var_id_val,
|
186 |
+
'name': _product_name,
|
187 |
+
'price': product_var.display_price,
|
188 |
+
'category': _product_category,
|
189 |
+
'variant': _tmp.join(','),
|
190 |
+
'quantity': jQuery( 'form.cart:first input[name=quantity]' ).val(),
|
191 |
+
'stocklevel': _product_stocklevel
|
192 |
+
}]
|
193 |
+
}
|
194 |
+
}
|
195 |
+
});
|
196 |
+
|
197 |
+
}
|
198 |
+
});
|
199 |
+
*/
|
200 |
+
} else {
|
201 |
+
window[ gtm4wp_datalayer_name ].push({
|
202 |
+
'event': 'gtm4wp.addProductToCartEEC',
|
203 |
+
'ecommerce': {
|
204 |
+
'currencyCode': _product_currency,
|
205 |
+
'add': {
|
206 |
+
'products': [{
|
207 |
+
'id': gtm4wp_use_sku_instead ? _product_sku : _product_id,
|
208 |
+
'name': _product_name,
|
209 |
+
'price': _product_price,
|
210 |
+
'category': _product_category,
|
211 |
+
'quantity': jQuery( 'form.cart:first input[name=quantity]' ).val(),
|
212 |
+
'stocklevel': _product_stocklevel
|
213 |
+
}]
|
214 |
+
}
|
215 |
+
}
|
216 |
+
});
|
217 |
+
}
|
218 |
+
});
|
219 |
+
|
220 |
+
// track remove links in mini cart widget and on cart page
|
221 |
+
jQuery( document ).on( 'click', '.mini_cart_item a.remove,.product-remove a.remove', function() {
|
222 |
+
var productdata = jQuery( this );
|
223 |
+
|
224 |
+
var qty = 0;
|
225 |
+
var qty_element = jQuery( this ).closest( '.cart_item' ).find( '.product-quantity input.qty' );
|
226 |
+
if ( qty_element.length === 0 ) {
|
227 |
+
qty_element = jQuery( this ).closest( '.mini_cart_item' ).find( '.quantity' );
|
228 |
+
if ( qty_element.length > 0 ) {
|
229 |
+
qty = parseInt( qty_element.text() );
|
230 |
+
|
231 |
+
if ( Number.isNaN( qty ) ) {
|
232 |
+
qty = 0;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
} else {
|
236 |
+
qty = qty_element.val();
|
237 |
+
}
|
238 |
+
|
239 |
+
if ( qty === 0 ) {
|
240 |
+
return true;
|
241 |
+
}
|
242 |
+
|
243 |
+
window[ gtm4wp_datalayer_name ].push({
|
244 |
+
'event': 'gtm4wp.removeFromCartEEC',
|
245 |
+
'ecommerce': {
|
246 |
+
'remove': {
|
247 |
+
'products': [{
|
248 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
249 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
250 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
251 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
252 |
+
'variant': productdata.data( 'gtm4wp_product_variant' ),
|
253 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
254 |
+
'quantity': qty
|
255 |
+
}]
|
256 |
+
}
|
257 |
+
}
|
258 |
+
});
|
259 |
+
});
|
260 |
+
|
261 |
+
// track clicks in product lists
|
262 |
+
jQuery( document ).on( 'click', '.products li:not(.product-category) a:not(.add_to_cart_button):not(.quick-view-button),.products>div:not(.product-category) a:not(.add_to_cart_button):not(.quick-view-button),.widget-product-item', function( event ) {
|
263 |
+
// do nothing if GTM is blocked for some reason
|
264 |
+
if ( 'undefined' == typeof google_tag_manager ) {
|
265 |
+
return true;
|
266 |
+
}
|
267 |
+
|
268 |
+
var _productdata = jQuery( this ).closest( '.product' );
|
269 |
+
var productdata = '';
|
270 |
+
|
271 |
+
if ( _productdata.length > 0 ) {
|
272 |
+
productdata = _productdata.find( '.gtm4wp_productdata' );
|
273 |
+
|
274 |
+
} else {
|
275 |
+
_productdata = jQuery( this ).closest( '.products li' );
|
276 |
+
|
277 |
+
if ( _productdata.length > 0 ) {
|
278 |
+
productdata = _productdata.find( '.gtm4wp_productdata' );
|
279 |
+
|
280 |
+
} else {
|
281 |
+
_productdata = jQuery( this ).closest( '.products>div' );
|
282 |
+
|
283 |
+
if ( _productdata.length > 0 ) {
|
284 |
+
productdata = _productdata.find( '.gtm4wp_productdata' );
|
285 |
+
} else {
|
286 |
+
productdata = jQuery( this );
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
if ( ( 'undefined' == typeof productdata.data( 'gtm4wp_product_id' ) ) || ( '' == productdata.data( 'gtm4wp_product_id' ) ) ) {
|
292 |
+
return true;
|
293 |
+
}
|
294 |
+
|
295 |
+
// only act on links pointing to the product detail page
|
296 |
+
if ( productdata.data( 'gtm4wp_product_url' ) != jQuery( this ).attr( 'href' ) ) {
|
297 |
+
return true;
|
298 |
+
}
|
299 |
+
|
300 |
+
var ctrl_key_pressed = event.ctrlKey;
|
301 |
+
|
302 |
+
event.preventDefault();
|
303 |
+
if ( ctrl_key_pressed ) {
|
304 |
+
// we need to open the new tab/page here so that popup blocker of the browser doesn't block our code
|
305 |
+
var _productpage = window.open( 'about:blank', '_blank' );
|
306 |
+
}
|
307 |
+
|
308 |
+
window[ gtm4wp_datalayer_name ].push({
|
309 |
+
'event': 'gtm4wp.productClickEEC',
|
310 |
+
'ecommerce': {
|
311 |
+
'currencyCode': gtm4wp_currency,
|
312 |
+
'click': {
|
313 |
+
'actionField': {'list': productdata.data( 'gtm4wp_productlist_name' )},
|
314 |
+
'products': [{
|
315 |
+
'id': productdata.data( 'gtm4wp_product_id' ),
|
316 |
+
'name': productdata.data( 'gtm4wp_product_name' ),
|
317 |
+
'price': productdata.data( 'gtm4wp_product_price' ),
|
318 |
+
'category': productdata.data( 'gtm4wp_product_cat' ),
|
319 |
+
'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ),
|
320 |
+
'position': productdata.data( 'gtm4wp_product_listposition' )
|
321 |
+
}]
|
322 |
+
}
|
323 |
+
},
|
324 |
+
'eventCallback': function() {
|
325 |
+
if ( ctrl_key_pressed && _productpage ) {
|
326 |
+
_productpage.location.href= productdata.data( 'gtm4wp_product_url' );
|
327 |
+
} else {
|
328 |
+
document.location.href = productdata.data( 'gtm4wp_product_url' );
|
329 |
+
}
|
330 |
+
},
|
331 |
+
'eventTimeout': 2000
|
332 |
+
});
|
333 |
+
});
|
334 |
+
|
335 |
+
// track variable products on their detail pages
|
336 |
+
jQuery( document ).on( 'found_variation', function( event, product_variation ) {
|
337 |
+
if ( "undefined" == typeof product_variation ) {
|
338 |
+
// some ither plugins trigger this event without variation data
|
339 |
+
return;
|
340 |
+
}
|
341 |
+
|
342 |
+
var _product_form = event.target;
|
343 |
+
var _product_var_id = jQuery( '[name=variation_id]', _product_form );
|
344 |
+
var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val();
|
345 |
+
var _product_name = jQuery( '[name=gtm4wp_name]', _product_form ).val();
|
346 |
+
var _product_sku = jQuery( '[name=gtm4wp_sku]', _product_form ).val();
|
347 |
+
var _product_category = jQuery( '[name=gtm4wp_category]', _product_form ).val();
|
348 |
+
var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val();
|
349 |
+
var _product_currency = jQuery( '[name=gtm4wp_currency]', _product_form ).val();
|
350 |
+
var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val();
|
351 |
+
|
352 |
+
var current_product_detail_data = {
|
353 |
+
name: _product_name,
|
354 |
+
id: 0,
|
355 |
+
price: 0,
|
356 |
+
category: _product_category,
|
357 |
+
stocklevel: _product_stocklevel,
|
358 |
+
variant: ''
|
359 |
+
};
|
360 |
+
|
361 |
+
current_product_detail_data.id = product_variation.variation_id;
|
362 |
+
if ( gtm4wp_use_sku_instead && product_variation.sku && ('' !== product_variation.sku) ) {
|
363 |
+
current_product_detail_data.id = product_variation.sku;
|
364 |
+
}
|
365 |
+
current_product_detail_data.price = product_variation.display_price;
|
366 |
+
|
367 |
+
var _tmp = [];
|
368 |
+
for( var attrib_key in product_variation.attributes ) {
|
369 |
+
_tmp.push( product_variation.attributes[ attrib_key ] );
|
370 |
+
}
|
371 |
+
current_product_detail_data.variant = _tmp.join(',');
|
372 |
+
gtm4wp_last_selected_product_variation = current_product_detail_data;
|
373 |
+
|
374 |
+
window[ gtm4wp_datalayer_name ].push({
|
375 |
+
'event': 'gtm4wp.changeDetailViewEEC',
|
376 |
+
'ecommerce': {
|
377 |
+
'currencyCode': _product_currency,
|
378 |
+
'detail': {
|
379 |
+
'products': [current_product_detail_data]
|
380 |
+
},
|
381 |
+
},
|
382 |
+
'ecomm_prodid': gtm4wp_id_prefix + current_product_detail_data.id,
|
383 |
+
'ecomm_pagetype': 'product',
|
384 |
+
'ecomm_totalvalue': current_product_detail_data.price
|
385 |
+
});
|
386 |
+
});
|
387 |
+
jQuery( '.variations select' ).trigger( 'change' );
|
388 |
+
|
389 |
+
// initiate codes in WooCommere Quick View
|
390 |
+
jQuery( document ).ajaxSuccess( function( event, xhr, settings ) {
|
391 |
+
if ( settings.url.indexOf( 'wc-api=WC_Quick_View' ) > -1 ) {
|
392 |
+
setTimeout( function() {
|
393 |
+
jQuery( ".woocommerce.quick-view" ).parent().find( "script" ).each( function(i) {
|
394 |
+
eval( jQuery( this ).text() );
|
395 |
+
});
|
396 |
+
}, 500);
|
397 |
+
}
|
398 |
+
});
|
399 |
+
|
400 |
+
// codes for enhanced ecommerce events on cart page
|
401 |
+
if ( is_cart ) {
|
402 |
+
jQuery( document ).on( 'click', '[name=update_cart]', function() {
|
403 |
+
gtm4wp_handle_cart_qty_change();
|
404 |
+
});
|
405 |
+
|
406 |
+
jQuery( document ).on( 'keypress', '.woocommerce-cart-form input[type=number]', function() {
|
407 |
+
gtm4wp_handle_cart_qty_change();
|
408 |
+
});
|
409 |
+
}
|
410 |
+
|
411 |
+
// codes for enhanced ecommerce events on checkout page
|
412 |
+
if ( is_checkout ) {
|
413 |
+
window.gtm4wp_checkout_step_offset = window.gtm4wp_checkout_step_offset || 0;
|
414 |
+
window.gtm4wp_checkout_products = window.gtm4wp_checkout_products || [];
|
415 |
+
var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here
|
416 |
+
|
417 |
+
jQuery( document ).on( 'blur', 'input[name^=shipping_]:not(input[name=shipping_method])', function() {
|
418 |
+
// do not report checkout step if already reported
|
419 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping' ) > -1 ) {
|
420 |
+
return;
|
421 |
+
}
|
422 |
+
|
423 |
+
// do not report checkout step if user is traversing through the section without filling in any data
|
424 |
+
if ( jQuery( this ).val().trim() == '' ) {
|
425 |
+
return;
|
426 |
+
}
|
427 |
+
|
428 |
+
window[ gtm4wp_datalayer_name ].push({
|
429 |
+
'event': 'gtm4wp.checkoutStepEEC',
|
430 |
+
'ecommerce': {
|
431 |
+
'checkout': {
|
432 |
+
'actionField': {
|
433 |
+
'step': 2 + window.gtm4wp_checkout_step_offset
|
434 |
+
},
|
435 |
+
'products': window.gtm4wp_checkout_products
|
436 |
+
}
|
437 |
+
}
|
438 |
+
});
|
439 |
+
|
440 |
+
gtm4wp_checkout_step_fired.push( 'shipping' );
|
441 |
+
});
|
442 |
+
|
443 |
+
jQuery( document ).on( 'click', 'input[name=shipping_method]', function() {
|
444 |
+
// do not report checkout step if already reported
|
445 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) > -1 ) {
|
446 |
+
return;
|
447 |
+
}
|
448 |
+
|
449 |
+
// do not fire event during page load
|
450 |
+
if ( 'complete' != document.readyState ) {
|
451 |
+
return;
|
452 |
+
}
|
453 |
+
|
454 |
+
window[ gtm4wp_datalayer_name ].push({
|
455 |
+
'event': 'gtm4wp.checkoutStepEEC',
|
456 |
+
'ecommerce': {
|
457 |
+
'checkout': {
|
458 |
+
'actionField': {
|
459 |
+
'step': 3 + window.gtm4wp_checkout_step_offset
|
460 |
+
},
|
461 |
+
'products': window.gtm4wp_checkout_products
|
462 |
+
}
|
463 |
+
}
|
464 |
+
});
|
465 |
+
|
466 |
+
gtm4wp_checkout_step_fired.push( 'shipping_method' );
|
467 |
+
});
|
468 |
+
|
469 |
+
jQuery( document ).on( 'click', 'input[name=payment_method]', function() {
|
470 |
+
// do not report checkout step if already reported
|
471 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) > -1 ) {
|
472 |
+
return;
|
473 |
+
}
|
474 |
+
|
475 |
+
// do not fire event during page load
|
476 |
+
if ( 'complete' != document.readyState ) {
|
477 |
+
return;
|
478 |
+
}
|
479 |
+
|
480 |
+
window[ gtm4wp_datalayer_name ].push({
|
481 |
+
'event': 'gtm4wp.checkoutStepEEC',
|
482 |
+
'ecommerce': {
|
483 |
+
'checkout': {
|
484 |
+
'actionField': {
|
485 |
+
'step': 4 + window.gtm4wp_checkout_step_offset
|
486 |
+
},
|
487 |
+
'products': window.gtm4wp_checkout_products
|
488 |
+
}
|
489 |
+
}
|
490 |
+
});
|
491 |
+
|
492 |
+
gtm4wp_checkout_step_fired.push( 'payment_method' );
|
493 |
+
});
|
494 |
+
|
495 |
+
jQuery( 'form[name=checkout]' ).on( 'submit', function() {
|
496 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) {
|
497 |
+
// shipping methods are not visible if only one is available
|
498 |
+
// and if the user has already a pre-selected method, no click event will fire to report the checkout step
|
499 |
+
jQuery( 'input[name=shipping_method]:checked' ).trigger( 'click' );
|
500 |
+
|
501 |
+
gtm4wp_checkout_step_fired.push( 'shipping_method' );
|
502 |
+
}
|
503 |
+
|
504 |
+
if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) == -1 ) {
|
505 |
+
// if the user has already a pre-selected method, no click event will fire to report the checkout step
|
506 |
+
jQuery( 'input[name=payment_method]:checked' ).trigger( 'click' );
|
507 |
+
|
508 |
+
gtm4wp_checkout_step_fired.push( 'payment_method' );
|
509 |
+
}
|
510 |
+
|
511 |
+
var _shipping_el = jQuery( '#shipping_method input:checked' );
|
512 |
+
if ( _shipping_el.length > 0 ) {
|
513 |
+
window[ gtm4wp_datalayer_name ].push({
|
514 |
+
'event': 'gtm4wp.checkoutOptionEEC',
|
515 |
+
'ecommerce': {
|
516 |
+
'checkout_option': {
|
517 |
+
'actionField': {
|
518 |
+
'step': 3 + window.gtm4wp_checkout_step_offset,
|
519 |
+
'option': 'Shipping: ' + _shipping_el.val()
|
520 |
+
}
|
521 |
+
}
|
522 |
+
}
|
523 |
+
});
|
524 |
+
}
|
525 |
+
|
526 |
+
var _payment_el = jQuery( '.payment_methods input:checked' );
|
527 |
+
if ( _payment_el.length > 0 ) {
|
528 |
+
window[ gtm4wp_datalayer_name ].push({
|
529 |
+
'event': 'gtm4wp.checkoutOptionEEC',
|
530 |
+
'ecommerce': {
|
531 |
+
'checkout_option': {
|
532 |
+
'actionField': {
|
533 |
+
'step': 4 + window.gtm4wp_checkout_step_offset,
|
534 |
+
'option': 'Payment: ' + _payment_el.val()
|
535 |
+
}
|
536 |
+
}
|
537 |
+
}
|
538 |
+
});
|
539 |
+
}
|
540 |
+
});
|
541 |
+
}
|
542 |
+
|
543 |
+
// codes for AdWords dynamic remarketing
|
544 |
+
if ( window.gtm4wp_remarketing&& !is_cart && !is_checkout ) {
|
545 |
+
if ( jQuery( '.gtm4wp_productdata' ).length > 0 ) {
|
546 |
+
for( var i=0; i<window[ gtm4wp_datalayer_name ].length; i++ ) {
|
547 |
+
if ( window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ] ) {
|
548 |
+
break;
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
if ( i == window[ gtm4wp_datalayer_name ].length ) {
|
553 |
+
// no existing dyn remarketing data found in the datalayer
|
554 |
+
i = 0;
|
555 |
+
window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ] = [];
|
556 |
+
}
|
557 |
+
|
558 |
+
if ( 'undefined' == typeof window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ].push ) {
|
559 |
+
return false;
|
560 |
+
}
|
561 |
+
|
562 |
+
var productdata;
|
563 |
+
jQuery( '.gtm4wp_productdata' ).each( function() {
|
564 |
+
productdata = jQuery( this );
|
565 |
+
|
566 |
+
window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ].push( gtm4wp_id_prefix + productdata.data( 'gtm4wp_product_id' ) );
|
567 |
+
});
|
568 |
+
}
|
569 |
+
}
|
570 |
+
});
|
js/gtm4wp-youtube.js
CHANGED
@@ -1,221 +1,221 @@
|
|
1 |
-
var gtm4wp_youtube_percentage_tracking = 10;
|
2 |
-
var gtm4wp_youtube_percentage_tracking_timeouts = {};
|
3 |
-
var gtm4wp_youtube_percentage_tracking_marks = {};
|
4 |
-
|
5 |
-
if ( typeof onYouTubeIframeAPIReady === "undefined" ) {
|
6 |
-
window.onYouTubeIframeAPIReady = function() {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
gtm4wp_jqthis.attr( "id", playerID );
|
22 |
-
|
23 |
-
|
24 |
-
var gtm4wp_yturl = gtm4wp_jqthis.attr( "src" );
|
25 |
-
if ( gtm4wp_yturl.indexOf( "enablejsapi=1" ) == -1 ) {
|
26 |
-
if ( gtm4wp_yturl.indexOf( "?" ) == -1 ) {
|
27 |
-
gtm4wp_yturl += "?";
|
28 |
-
}
|
29 |
-
|
30 |
-
gtm4wp_yturl += "&enablejsapi=1&origin=" + document.location.protocol + "//" + document.location.hostname;
|
31 |
-
|
32 |
-
gtm4wp_jqthis.attr( "src", gtm4wp_yturl );
|
33 |
-
}
|
34 |
-
|
35 |
-
player = new YT.Player( playerID, {
|
36 |
-
events: {
|
37 |
-
'onReady': gtm4wp_onYouTubePlayerReady,
|
38 |
-
'onStateChange': gtm4wp_onYouTubePlayerStateChange,
|
39 |
-
'onPlaybackQualityChange': gtm4wp_onYouTubePlaybackQualityChange,
|
40 |
-
'onPlaybackRateChange': gtm4wp_onYouTubePlaybackRateChange,
|
41 |
-
'onError': gtm4wp_onYouTubeError,
|
42 |
-
'onApiChange': gtm4wp_onYouTubeApiChange
|
43 |
-
}
|
44 |
-
});
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
var tag = document.createElement( 'script' );
|
49 |
-
tag.src = "//www.youtube.com/iframe_api";
|
50 |
-
var firstScriptTag = document.getElementsByTagName( 'script' )[0];
|
51 |
-
firstScriptTag.parentNode.insertBefore( tag, firstScriptTag );
|
52 |
-
} else {
|
53 |
-
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
function gtm4wp_onYouTubePlayerReady( event ) {
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
function gtm4wp_onYouTubePlayerStateChange( event ) {
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
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 |
-
function gtm4wp_onYouTubePlaybackQualityChange( event ) {
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
function gtm4wp_onYouTubePlaybackRateChange( event ) {
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
function gtm4wp_onYouTubeError( event ) {
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
}
|
170 |
-
|
171 |
-
function gtm4wp_onYouTubeApiChange( event ) {
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
function gtm4wp_onYouTubePercentageChange( event ) {
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
gtm4wp_youtube_percentage_tracking_marks[ videoId ].push( i );
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
}
|
1 |
+
var gtm4wp_youtube_percentage_tracking = 10;
|
2 |
+
var gtm4wp_youtube_percentage_tracking_timeouts = {};
|
3 |
+
var gtm4wp_youtube_percentage_tracking_marks = {};
|
4 |
+
|
5 |
+
if ( typeof onYouTubeIframeAPIReady === "undefined" ) {
|
6 |
+
window.onYouTubeIframeAPIReady = function() {
|
7 |
+
window[ gtm4wp_datalayer_name ].push({
|
8 |
+
'event': 'gtm4wp.mediaApiReady',
|
9 |
+
'mediaType': 'youtube'
|
10 |
+
});
|
11 |
+
|
12 |
+
jQuery( "iframe[src^='https://www.youtube.com/embed']" ).each( function() {
|
13 |
+
var gtm4wp_jqthis = jQuery( this );
|
14 |
+
var playerID = gtm4wp_jqthis.attr( "id" );
|
15 |
+
|
16 |
+
if ( ( playerID === undefined ) || ( playerID === "" ) ) {
|
17 |
+
var _gtm4wp_temp = gtm4wp_jqthis.attr( "src" ).split( "?" );
|
18 |
+
var _gtm4wp_temp2 = _gtm4wp_temp[ 0 ].split( "/" );
|
19 |
+
|
20 |
+
playerID = "youtubeplayer_" + _gtm4wp_temp2[ _gtm4wp_temp2.length-1 ];
|
21 |
+
gtm4wp_jqthis.attr( "id", playerID );
|
22 |
+
}
|
23 |
+
|
24 |
+
var gtm4wp_yturl = gtm4wp_jqthis.attr( "src" );
|
25 |
+
if ( gtm4wp_yturl.indexOf( "enablejsapi=1" ) == -1 ) {
|
26 |
+
if ( gtm4wp_yturl.indexOf( "?" ) == -1 ) {
|
27 |
+
gtm4wp_yturl += "?";
|
28 |
+
}
|
29 |
+
|
30 |
+
gtm4wp_yturl += "&enablejsapi=1&origin=" + document.location.protocol + "//" + document.location.hostname;
|
31 |
+
|
32 |
+
gtm4wp_jqthis.attr( "src", gtm4wp_yturl );
|
33 |
+
}
|
34 |
+
|
35 |
+
player = new YT.Player( playerID, {
|
36 |
+
events: {
|
37 |
+
'onReady': gtm4wp_onYouTubePlayerReady,
|
38 |
+
'onStateChange': gtm4wp_onYouTubePlayerStateChange,
|
39 |
+
'onPlaybackQualityChange': gtm4wp_onYouTubePlaybackQualityChange,
|
40 |
+
'onPlaybackRateChange': gtm4wp_onYouTubePlaybackRateChange,
|
41 |
+
'onError': gtm4wp_onYouTubeError,
|
42 |
+
'onApiChange': gtm4wp_onYouTubeApiChange
|
43 |
+
}
|
44 |
+
});
|
45 |
+
});
|
46 |
+
};
|
47 |
+
|
48 |
+
var tag = document.createElement( 'script' );
|
49 |
+
tag.src = "//www.youtube.com/iframe_api";
|
50 |
+
var firstScriptTag = document.getElementsByTagName( 'script' )[0];
|
51 |
+
firstScriptTag.parentNode.insertBefore( tag, firstScriptTag );
|
52 |
+
} else {
|
53 |
+
var gtm4wp_err = new Error( "Another code is already utilizing YouTube API, GTM4WP plugin can not load YouTube tracking!" );
|
54 |
+
throw gtm4wp_err;
|
55 |
+
}
|
56 |
+
|
57 |
+
function gtm4wp_onYouTubePlayerReady( event ) {
|
58 |
+
var videodata = event.target.getVideoData();
|
59 |
+
|
60 |
+
window[ gtm4wp_datalayer_name ].push({
|
61 |
+
'event': 'gtm4wp.mediaPlayerReady',
|
62 |
+
'mediaType': 'youtube',
|
63 |
+
'mediaData': {
|
64 |
+
'id': videodata.video_id,
|
65 |
+
'author': videodata.author,
|
66 |
+
'title': videodata.title,
|
67 |
+
'url': event.target.getVideoUrl(),
|
68 |
+
'duration': event.target.getDuration()
|
69 |
+
},
|
70 |
+
'mediaCurrentTime': event.target.getCurrentTime()
|
71 |
+
});
|
72 |
+
}
|
73 |
+
|
74 |
+
function gtm4wp_onYouTubePlayerStateChange( event ) {
|
75 |
+
var playerState = "unknown";
|
76 |
+
switch( event.data ) {
|
77 |
+
case -1: playerState = "unstarted"; break;
|
78 |
+
case YT.PlayerState.ENDED: playerState = "ended"; break;
|
79 |
+
case YT.PlayerState.PLAYING: playerState = "play"; break;
|
80 |
+
case YT.PlayerState.PAUSED: playerState = "pause"; break;
|
81 |
+
case YT.PlayerState.BUFFERING: playerState = "buffering"; break;
|
82 |
+
case YT.PlayerState.CUED: playerState = "cued"; break;
|
83 |
+
}
|
84 |
+
|
85 |
+
var videoId = event.target.getVideoData().video_id;
|
86 |
+
|
87 |
+
if ( ( YT.PlayerState.PLAYING == event.data ) && ( gtm4wp_youtube_percentage_tracking > 0 ) ) {
|
88 |
+
gtm4wp_youtube_percentage_tracking_timeouts[ videoId ] = setInterval(function() {
|
89 |
+
gtm4wp_onYouTubePercentageChange( event );
|
90 |
+
}, 1000);
|
91 |
+
} else {
|
92 |
+
if ( gtm4wp_youtube_percentage_tracking_timeouts[ videoId ] ) {
|
93 |
+
clearInterval( gtm4wp_youtube_percentage_tracking_timeouts[ videoId ] );
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
var videodata = event.target.getVideoData();
|
98 |
+
|
99 |
+
window[ gtm4wp_datalayer_name ].push({
|
100 |
+
'event': 'gtm4wp.mediaPlayerStateChange',
|
101 |
+
'mediaType': 'youtube',
|
102 |
+
'mediaData': {
|
103 |
+
'id': videodata.video_id,
|
104 |
+
'author': videodata.author,
|
105 |
+
'title': videodata.title,
|
106 |
+
'url': event.target.getVideoUrl(),
|
107 |
+
'duration': event.target.getDuration()
|
108 |
+
},
|
109 |
+
'mediaPlayerState': playerState,
|
110 |
+
'mediaCurrentTime': event.target.getCurrentTime()
|
111 |
+
});
|
112 |
+
}
|
113 |
+
|
114 |
+
function gtm4wp_onYouTubePlaybackQualityChange( event ) {
|
115 |
+
var videodata = event.target.getVideoData();
|
116 |
+
|
117 |
+
window[ gtm4wp_datalayer_name ].push({
|
118 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
119 |
+
'mediaType': 'youtube',
|
120 |
+
'mediaData': {
|
121 |
+
'id': videodata.video_id,
|
122 |
+
'author': videodata.author,
|
123 |
+
'title': videodata.title,
|
124 |
+
'url': event.target.getVideoUrl(),
|
125 |
+
'duration': event.target.getDuration()
|
126 |
+
},
|
127 |
+
'mediaCurrentTime': event.target.getCurrentTime(),
|
128 |
+
'mediaPlayerEvent': 'quality-change',
|
129 |
+
'mediaPlayerEventParam': event.data
|
130 |
+
});
|
131 |
+
}
|
132 |
+
|
133 |
+
function gtm4wp_onYouTubePlaybackRateChange( event ) {
|
134 |
+
var videodata = event.target.getVideoData();
|
135 |
+
|
136 |
+
window[ gtm4wp_datalayer_name ].push({
|
137 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
138 |
+
'mediaType': 'youtube',
|
139 |
+
'mediaData': {
|
140 |
+
'id': videodata.video_id,
|
141 |
+
'author': videodata.author,
|
142 |
+
'title': videodata.title,
|
143 |
+
'url': event.target.getVideoUrl(),
|
144 |
+
'duration': event.target.getDuration()
|
145 |
+
},
|
146 |
+
'mediaCurrentTime': event.target.getCurrentTime(),
|
147 |
+
'mediaPlayerEvent': 'ratechange',
|
148 |
+
'mediaPlayerEventParam': event.data
|
149 |
+
});
|
150 |
+
}
|
151 |
+
|
152 |
+
function gtm4wp_onYouTubeError( event ) {
|
153 |
+
var videodata = event.target.getVideoData();
|
154 |
+
|
155 |
+
window[ gtm4wp_datalayer_name ].push({
|
156 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
157 |
+
'mediaType': 'youtube',
|
158 |
+
'mediaData': {
|
159 |
+
'id': videodata.video_id,
|
160 |
+
'author': videodata.author,
|
161 |
+
'title': videodata.title,
|
162 |
+
'url': event.target.getVideoUrl(),
|
163 |
+
'duration': event.target.getDuration()
|
164 |
+
},
|
165 |
+
'mediaCurrentTime': event.target.getCurrentTime(),
|
166 |
+
'mediaPlayerEvent': 'error',
|
167 |
+
'mediaPlayerEventParam': event.data
|
168 |
+
});
|
169 |
+
}
|
170 |
+
|
171 |
+
function gtm4wp_onYouTubeApiChange( event ) {
|
172 |
+
var videodata = event.target.getVideoData();
|
173 |
+
|
174 |
+
window[ gtm4wp_datalayer_name ].push({
|
175 |
+
'event': 'gtm4wp.mediaPlayerEvent',
|
176 |
+
'mediaType': 'youtube',
|
177 |
+
'mediaData': {
|
178 |
+
'id': videodata.video_id,
|
179 |
+
'author': videodata.author,
|
180 |
+
'title': videodata.title,
|
181 |
+
'url': event.target.getVideoUrl(),
|
182 |
+
'duration': event.target.getDuration()
|
183 |
+
},
|
184 |
+
'mediaCurrentTime': event.target.getCurrentTime(),
|
185 |
+
'mediaPlayerEvent': 'api-change',
|
186 |
+
'mediaPlayerEventParam': event.data
|
187 |
+
});
|
188 |
+
}
|
189 |
+
|
190 |
+
function gtm4wp_onYouTubePercentageChange( event ) {
|
191 |
+
var videoId = event.target.getVideoData().video_id;
|
192 |
+
var videoCurrentTime = event.target.getCurrentTime();
|
193 |
+
var videoDuration = event.target.getDuration();
|
194 |
+
var videoPercentage = Math.floor( videoCurrentTime / videoDuration * 100 );
|
195 |
+
|
196 |
+
if ( typeof gtm4wp_youtube_percentage_tracking_marks[ videoId ] == "undefined" ) {
|
197 |
+
gtm4wp_youtube_percentage_tracking_marks[ videoId ] = [];
|
198 |
+
}
|
199 |
+
|
200 |
+
var videodata = event.target.getVideoData();
|
201 |
+
|
202 |
+
for( var i=0; i<100; i+=gtm4wp_youtube_percentage_tracking ) {
|
203 |
+
if ( ( videoPercentage > i ) && ( gtm4wp_youtube_percentage_tracking_marks[ videoId ].indexOf( i ) == -1 ) ) {
|
204 |
+
gtm4wp_youtube_percentage_tracking_marks[ videoId ].push( i );
|
205 |
+
|
206 |
+
window[ gtm4wp_datalayer_name ].push({
|
207 |
+
'event': 'gtm4wp.mediaPlaybackPercentage',
|
208 |
+
'mediaType': 'youtube',
|
209 |
+
'mediaData': {
|
210 |
+
'id': videodata.video_id,
|
211 |
+
'author': videodata.author,
|
212 |
+
'title': videodata.title,
|
213 |
+
'url': event.target.getVideoUrl(),
|
214 |
+
'duration': event.target.getDuration()
|
215 |
+
},
|
216 |
+
'mediaCurrentTime': event.target.getCurrentTime(),
|
217 |
+
'mediaPercentage': i
|
218 |
+
});
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
public/frontend.php
CHANGED
@@ -1,785 +1,897 @@
|
|
1 |
-
<?php
|
2 |
-
define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER', 'gtm4wp_compile_datalayer' );
|
3 |
-
define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtm4wp_compile_remarkering' );
|
4 |
-
define( '
|
5 |
-
define( '
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
if (
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
if
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
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 |
-
|
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 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
$
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
$
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
$
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
if ( $gtm4wp_options[
|
358 |
-
$
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
if ( $gtm4wp_options[
|
370 |
-
$
|
371 |
-
}
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
$
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
if ( $gtm4wp_options[
|
403 |
-
$
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
$
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
$
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
$
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
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 |
-
|
482 |
-
if (
|
483 |
-
$
|
484 |
-
|
485 |
-
if (
|
486 |
-
|
487 |
-
|
488 |
-
$
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
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 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
}
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
}
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
}
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
}
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
if
|
690 |
-
$
|
691 |
-
|
692 |
-
|
693 |
-
}
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
' . $gtm4wp_datalayer_name . '
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
}
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
$
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
}
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Converts bool false to string false for JS
|
34 |
+
*
|
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 |
+
if ( !function_exists( "getallheaders") ) {
|
53 |
+
function getallheaders() {
|
54 |
+
$headers = array();
|
55 |
+
foreach ( $_SERVER as $name => $value ) {
|
56 |
+
if ( substr($name, 0, 5) == "HTTP_" ) {
|
57 |
+
$headers[ str_replace(' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
return $headers;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
66 |
+
global $wp_query, $gtm4wp_options;
|
67 |
+
|
68 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_DONOTTRACK ] ) {
|
69 |
+
if ( !empty( $_SERVER['HTTP_DNT'] ) ) {
|
70 |
+
$dataLayer["visitorDoNotTrack"] = (int)($_SERVER['HTTP_DNT']);
|
71 |
+
} else {
|
72 |
+
$dataLayer["visitorDoNotTrack"] = 0;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_SITEID ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_SITENAME ] ) {
|
77 |
+
$dataLayer["siteID"] = 0;
|
78 |
+
$dataLayer["siteName"] = "";
|
79 |
+
|
80 |
+
if ( function_exists( 'get_blog_details' ) ) {
|
81 |
+
$gtm4wp_blogdetails = get_blog_details();
|
82 |
+
|
83 |
+
$dataLayer["siteID"] = $gtm4wp_blogdetails->blog_id;
|
84 |
+
$dataLayer["siteName"] = $gtm4wp_blogdetails->blogname;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_LOGGEDIN ] ) {
|
89 |
+
if ( is_user_logged_in() ) {
|
90 |
+
$dataLayer["visitorLoginState"] = "logged-in";
|
91 |
+
} else {
|
92 |
+
$dataLayer["visitorLoginState"] = "logged-out";
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERROLE ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USEREMAIL ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERREGDATE ] ) {
|
97 |
+
$current_user = wp_get_current_user();
|
98 |
+
|
99 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERROLE ] ) {
|
100 |
+
$dataLayer["visitorType"] = ( empty( $current_user->roles[0] ) ? "visitor-logged-out" : $current_user->roles[0] );
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USEREMAIL ] ) {
|
104 |
+
$dataLayer["visitorEmail"] = ( empty( $current_user->user_email ) ? "" : $current_user->user_email );
|
105 |
+
}
|
106 |
+
|
107 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERREGDATE ] ) {
|
108 |
+
$dataLayer["visitorRegistrationDate"] = ( empty( $current_user->user_registered ) ? "" : strtotime($current_user->user_registered) );
|
109 |
+
}
|
110 |
+
|
111 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERNAME ] ) {
|
112 |
+
$dataLayer["visitorUsername"] = ( empty( $current_user->user_login ) ? "" : $current_user->user_login );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERID ] ) {
|
117 |
+
$_gtm4wp_userid = get_current_user_id();
|
118 |
+
if ( $_gtm4wp_userid > 0 ) {
|
119 |
+
$dataLayer["visitorId"] = $_gtm4wp_userid;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_VISITOR_IP ] ) {
|
124 |
+
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
|
125 |
+
//check ip from shared internet
|
126 |
+
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
127 |
+
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
128 |
+
//to check ip is passed from proxy
|
129 |
+
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
130 |
+
} else {
|
131 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
132 |
+
}
|
133 |
+
|
134 |
+
$dataLayer["visitorIP"] = $ip;
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
|
138 |
+
$dataLayer["pageTitle"] = strip_tags( wp_title( "|", false, "right" ) );
|
139 |
+
}
|
140 |
+
|
141 |
+
if ( is_singular() ) {
|
142 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
143 |
+
$dataLayer["pagePostType"] = get_post_type();
|
144 |
+
$dataLayer["pagePostType2"] = "single-".get_post_type();
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_CATEGORIES ] ) {
|
148 |
+
$_post_cats = get_the_category();
|
149 |
+
if ( $_post_cats ) {
|
150 |
+
$dataLayer["pageCategory"] = array();
|
151 |
+
foreach( $_post_cats as $_one_cat ) {
|
152 |
+
$dataLayer["pageCategory"][] = $_one_cat->slug;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_TAGS ] ) {
|
158 |
+
$_post_tags = get_the_tags();
|
159 |
+
if ( $_post_tags ) {
|
160 |
+
$dataLayer["pageAttributes"] = array();
|
161 |
+
foreach( $_post_tags as $_one_tag ) {
|
162 |
+
$dataLayer["pageAttributes"][] = $_one_tag->slug;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) {
|
168 |
+
$postuser = get_userdata( $GLOBALS["post"]->post_author );
|
169 |
+
|
170 |
+
if ( false !== $postuser ) {
|
171 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] ) {
|
172 |
+
$dataLayer["pagePostAuthorID"] = $postuser->ID;
|
173 |
+
}
|
174 |
+
|
175 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) {
|
176 |
+
$dataLayer["pagePostAuthor"] = $postuser->display_name;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
182 |
+
$dataLayer["pagePostDate"] = get_the_date();
|
183 |
+
$dataLayer["pagePostDateYear"] = get_the_date( "Y" );
|
184 |
+
$dataLayer["pagePostDateMonth"] = get_the_date( "m" );
|
185 |
+
$dataLayer["pagePostDateDay"] = get_the_date( "d" );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
if ( is_archive() || is_post_type_archive() ) {
|
190 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
191 |
+
$dataLayer["pagePostType"] = get_post_type();
|
192 |
+
|
193 |
+
if ( is_category() ) {
|
194 |
+
$dataLayer["pagePostType2"] = "category-".get_post_type();
|
195 |
+
} else if ( is_tag() ) {
|
196 |
+
$dataLayer["pagePostType2"] = "tag-".get_post_type();
|
197 |
+
} else if ( is_tax() ) {
|
198 |
+
$dataLayer["pagePostType2"] = "tax-".get_post_type();
|
199 |
+
} else if ( is_author() ) {
|
200 |
+
$dataLayer["pagePostType2"] = "author-".get_post_type();
|
201 |
+
} else if ( is_year() ) {
|
202 |
+
$dataLayer["pagePostType2"] = "year-".get_post_type();
|
203 |
+
|
204 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
205 |
+
$dataLayer["pagePostDateYear"] = get_the_date( "Y" );
|
206 |
+
}
|
207 |
+
} else if ( is_month() ) {
|
208 |
+
$dataLayer["pagePostType2"] = "month-".get_post_type();
|
209 |
+
|
210 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
211 |
+
$dataLayer["pagePostDateYear"] = get_the_date( "Y" );
|
212 |
+
$dataLayer["pagePostDateMonth"] = get_the_date( "m" );
|
213 |
+
}
|
214 |
+
} else if ( is_day() ) {
|
215 |
+
$dataLayer["pagePostType2"] = "day-".get_post_type();
|
216 |
+
|
217 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
218 |
+
$dataLayer["pagePostDate"] = get_the_date();
|
219 |
+
$dataLayer["pagePostDateYear"] = get_the_date( "Y" );
|
220 |
+
$dataLayer["pagePostDateMonth"] = get_the_date( "m" );
|
221 |
+
$dataLayer["pagePostDateDay"] = get_the_date( "d" );
|
222 |
+
}
|
223 |
+
} else if ( is_time() ) {
|
224 |
+
$dataLayer["pagePostType2"] = "time-".get_post_type();
|
225 |
+
} else if ( is_date() ) {
|
226 |
+
$dataLayer["pagePostType2"] = "date-".get_post_type();
|
227 |
+
|
228 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTDATE ] ) {
|
229 |
+
$dataLayer["pagePostDate"] = get_the_date();
|
230 |
+
$dataLayer["pagePostDateYear"] = get_the_date( "Y" );
|
231 |
+
$dataLayer["pagePostDateMonth"] = get_the_date( "m" );
|
232 |
+
$dataLayer["pagePostDateDay"] = get_the_date( "d" );
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
if ( ( is_tax() || is_category() ) && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_CATEGORIES ] ) {
|
238 |
+
$_post_cats = get_the_category();
|
239 |
+
$dataLayer["pageCategory"] = array();
|
240 |
+
foreach( $_post_cats as $_one_cat ) {
|
241 |
+
$dataLayer["pageCategory"][] = $_one_cat->slug;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHORID ] ) && ( is_author() ) ) {
|
246 |
+
global $authordata;
|
247 |
+
$dataLayer["pagePostAuthorID"] = isset( $authordata->ID ) ? $authordata->ID : 0;
|
248 |
+
}
|
249 |
+
|
250 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_AUTHOR ] ) && ( is_author() ) ) {
|
251 |
+
$dataLayer["pagePostAuthor"] = get_the_author();
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
if ( is_search() ) {
|
256 |
+
$dataLayer["siteSearchTerm"] = get_search_query();
|
257 |
+
$dataLayer["siteSearchFrom"] = ( isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "" );
|
258 |
+
$dataLayer["siteSearchResults"] = $wp_query->post_count;
|
259 |
+
}
|
260 |
+
|
261 |
+
if ( is_front_page() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
262 |
+
$dataLayer["pagePostType"] = "frontpage";
|
263 |
+
}
|
264 |
+
|
265 |
+
if ( !is_front_page() && is_home() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
266 |
+
$dataLayer["pagePostType"] = "bloghome";
|
267 |
+
}
|
268 |
+
|
269 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
270 |
+
spl_autoload_register( function( $class ) {
|
271 |
+
$class_parts = explode( "\\", $class );
|
272 |
+
if ( "WhichBrowser" == $class_parts[0] ) {
|
273 |
+
include dirname( __FILE__ ) . "/../integration/whichbrowser/" . str_replace( array( "WhichBrowser", "\\" ), array( "src", "/" ), $class ) . ".php";
|
274 |
+
}
|
275 |
+
});
|
276 |
+
|
277 |
+
require_once( dirname( __FILE__ ) . "/../integration/whichbrowser/src/Parser.php" );
|
278 |
+
|
279 |
+
$gtp4wp_headers = getallheaders();
|
280 |
+
if ( ( false === $gtp4wp_headers ) && isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
281 |
+
$gtp4wp_headers = $_SERVER['HTTP_USER_AGENT'];
|
282 |
+
}
|
283 |
+
if ( false !== $gtp4wp_headers ) {
|
284 |
+
$detected = new WhichBrowser\Parser($gtp4wp_headers);
|
285 |
+
|
286 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] ) {
|
287 |
+
$dataLayer["browserName"] = isset( $detected->browser->name ) ? $detected->browser->name : "";
|
288 |
+
$dataLayer["browserVersion"] = isset( $detected->browser->version->value ) ? $detected->browser->version->value : "";
|
289 |
+
|
290 |
+
$dataLayer["browserEngineName"] = isset( $detected->engine->name ) ? $detected->engine->name : "";
|
291 |
+
$dataLayer["browserEngineVersion"] = isset( $detected->engine->version->value ) ? $detected->engine->version->value : "";
|
292 |
+
}
|
293 |
+
|
294 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] ) {
|
295 |
+
$dataLayer["osName"] = isset( $detected->os->name ) ? $detected->os->name : "";
|
296 |
+
$dataLayer["osVersion"] = isset( $detected->os->version->value ) ? $detected->os->version->value : "";
|
297 |
+
}
|
298 |
+
|
299 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
300 |
+
$dataLayer["deviceType"] = isset( $detected->device->type ) ? $detected->device->type : "";
|
301 |
+
$dataLayer["deviceManufacturer"] = isset( $detected->device->manufacturer ) ? $detected->device->manufacturer : "";
|
302 |
+
$dataLayer["deviceModel"] = isset( $detected->device->model ) ? $detected->device->model : "";
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTCOUNT ] ) {
|
308 |
+
$dataLayer["postCountOnPage"] = (int) $wp_query->post_count;
|
309 |
+
$dataLayer["postCountTotal"] = (int) $wp_query->found_posts;
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTID ] && is_singular() === true) {
|
313 |
+
$dataLayer["postID"] = (int) get_the_ID();
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTFORMAT ] && is_singular() === true) {
|
317 |
+
$dataLayer["postFormat"] = get_post_format() ? : 'standard';
|
318 |
+
}
|
319 |
+
|
320 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] > 0 ) {
|
321 |
+
$_gtmrestrictlistitems = array();
|
322 |
+
|
323 |
+
// IDs from https://developers.google.com/tag-manager/devguide#security
|
324 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ADADVISOR ] ) {
|
325 |
+
$_gtmrestrictlistitems[] = "ta";
|
326 |
+
}
|
327 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ADROLL ] ) {
|
328 |
+
$_gtmrestrictlistitems[] = "asp";
|
329 |
+
}
|
330 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_AWCONV ] ) {
|
331 |
+
$_gtmrestrictlistitems[] = "awct";
|
332 |
+
}
|
333 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_AWREMARKET ] ) {
|
334 |
+
$_gtmrestrictlistitems[] = "sp";
|
335 |
+
}
|
336 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_BIZO ] ) {
|
337 |
+
$_gtmrestrictlistitems[] = "bzi";
|
338 |
+
}
|
339 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CLICKTALE ] ) {
|
340 |
+
$_gtmrestrictlistitems[] = "cts";
|
341 |
+
}
|
342 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_COMSCORE ] ) {
|
343 |
+
$_gtmrestrictlistitems[] = "csm";
|
344 |
+
}
|
345 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CUSTOMHTML ] ) {
|
346 |
+
$_gtmrestrictlistitems[] = "html";
|
347 |
+
}
|
348 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_CUSTOMIMG ] ) {
|
349 |
+
$_gtmrestrictlistitems[] = "img";
|
350 |
+
}
|
351 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_DBLCLKCOUNT ] ) {
|
352 |
+
$_gtmrestrictlistitems[] = "flc";
|
353 |
+
}
|
354 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_DBLCLKSALES ] ) {
|
355 |
+
$_gtmrestrictlistitems[] = "fls";
|
356 |
+
}
|
357 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_GACLASSIC ] ) {
|
358 |
+
$_gtmrestrictlistitems[] = "ga";
|
359 |
+
}
|
360 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MARIN ] ) {
|
361 |
+
$_gtmrestrictlistitems[] = "ms";
|
362 |
+
}
|
363 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MPLEXIFRAME ] ) {
|
364 |
+
$_gtmrestrictlistitems[] = "mpm";
|
365 |
+
}
|
366 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MPLEXROI ] ) {
|
367 |
+
$_gtmrestrictlistitems[] = "mpr";
|
368 |
+
}
|
369 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MEDIA6DEG ] ) {
|
370 |
+
$_gtmrestrictlistitems[] = "m6d";
|
371 |
+
}
|
372 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_TURNCONV ] ) {
|
373 |
+
$_gtmrestrictlistitems[] = "tc";
|
374 |
+
}
|
375 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_TURNDATA ] ) {
|
376 |
+
$_gtmrestrictlistitems[] = "tdc";
|
377 |
+
}
|
378 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_UA ] ) {
|
379 |
+
$_gtmrestrictlistitems[] = "ua";
|
380 |
+
}
|
381 |
+
|
382 |
+
$_gtmwhitelist = array();
|
383 |
+
$_gtmblacklist = array();
|
384 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 1 ) {
|
385 |
+
$_gtmblacklist = array_merge($_gtmblacklist, $_gtmrestrictlistitems);
|
386 |
+
} else {
|
387 |
+
$_gtmwhitelist = array_merge($_gtmwhitelist, $_gtmrestrictlistitems);
|
388 |
+
}
|
389 |
+
|
390 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_DOMELEMENT ] ) {
|
391 |
+
$_gtmwhitelist[] = "d";
|
392 |
+
}
|
393 |
+
|
394 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_CUSTOMJS ] ) {
|
395 |
+
$_gtmwhitelist[] = "jsm";
|
396 |
+
}
|
397 |
+
|
398 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_CONSTANT ] ) {
|
399 |
+
$_gtmwhitelist[] = "c";
|
400 |
+
}
|
401 |
+
|
402 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_1STCOOKIE ] ) {
|
403 |
+
$_gtmwhitelist[] = "k";
|
404 |
+
}
|
405 |
+
|
406 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_EVENTNAME ] ) {
|
407 |
+
$_gtmwhitelist[] = "e";
|
408 |
+
}
|
409 |
+
|
410 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_JSVAR ] ) {
|
411 |
+
$_gtmwhitelist[] = "j";
|
412 |
+
}
|
413 |
+
|
414 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_DLAYERVAR ] ) {
|
415 |
+
$_gtmwhitelist[] = "v";
|
416 |
+
}
|
417 |
+
|
418 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM ] ) {
|
419 |
+
$_gtmwhitelist[] = "r";
|
420 |
+
}
|
421 |
+
|
422 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER ] ) {
|
423 |
+
$_gtmwhitelist[] = "f";
|
424 |
+
}
|
425 |
+
|
426 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_URL ] ) {
|
427 |
+
$_gtmwhitelist[] = "u";
|
428 |
+
}
|
429 |
+
|
430 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT ] ) {
|
431 |
+
$_gtmwhitelist[] = "v";
|
432 |
+
}
|
433 |
+
|
434 |
+
$dataLayer[ "gtm.whitelist" ] = $_gtmwhitelist;
|
435 |
+
$dataLayer[ "gtm.blacklist" ] = $_gtmblacklist;
|
436 |
+
}
|
437 |
+
|
438 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ]) {
|
439 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
|
440 |
+
$dataLayer[ "weatherCategory" ] = __( "(no weather data available)", 'duracelltomi-google-tag-manager' );
|
441 |
+
$dataLayer[ "weatherDescription" ] = __( "(no weather data available)", 'duracelltomi-google-tag-manager' );
|
442 |
+
$dataLayer[ "weatherTemp" ] = 0;
|
443 |
+
$dataLayer[ "weatherPressure" ] = 0;
|
444 |
+
$dataLayer[ "weatherWindSpeed" ] = 0;
|
445 |
+
$dataLayer[ "weatherWindDeg" ] = 0;
|
446 |
+
$dataLayer[ "weatherDataStatus" ] = "Initialized with empty data";
|
447 |
+
}
|
448 |
+
|
449 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
|
450 |
+
$dataLayer[ "geoCountryCode" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
451 |
+
$dataLayer[ "geoCountryName" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
452 |
+
$dataLayer[ "geoRegionCode" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
453 |
+
$dataLayer[ "geoRegionName" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
454 |
+
$dataLayer[ "geoCity" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
455 |
+
$dataLayer[ "geoZipcode" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
456 |
+
$dataLayer[ "geoLatitude" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
457 |
+
$dataLayer[ "geoLongitude" ] = __( "(no geo data available)", 'duracelltomi-google-tag-manager' );
|
458 |
+
}
|
459 |
+
|
460 |
+
$gtm4wp_sessionid = array_key_exists( "gtm4wp_sessionid", $_COOKIE ) ? $_COOKIE[ "gtm4wp_sessionid" ] : "";
|
461 |
+
// this is needed so that nobody can do a hack by editing our cookie
|
462 |
+
$gtm4wp_sessionid = str_replace( "'", "", trim( basename( $gtm4wp_sessionid ) ) );
|
463 |
+
|
464 |
+
if ( "" !== $gtm4wp_sessionid ) {
|
465 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
|
466 |
+
$weatherdata = get_transient( 'gtm4wp-weatherdata-'.$gtm4wp_sessionid );
|
467 |
+
|
468 |
+
if ( false !== $weatherdata ) {
|
469 |
+
$dataLayer[ "weatherCategory" ] = $weatherdata->weather[0]->main;
|
470 |
+
$dataLayer[ "weatherDescription" ] = $weatherdata->weather[0]->description;
|
471 |
+
$dataLayer[ "weatherTemp" ] = $weatherdata->main->temp;
|
472 |
+
$dataLayer[ "weatherPressure" ] = $weatherdata->main->pressure;
|
473 |
+
$dataLayer[ "weatherWindSpeed" ] = $weatherdata->wind->speed;
|
474 |
+
$dataLayer[ "weatherWindDeg" ] = ($weatherdata->wind->deg ? $weatherdata->wind->deg : "");
|
475 |
+
$dataLayer[ "weatherFullWeatherData" ] = $weatherdata;
|
476 |
+
$dataLayer[ "weatherDataStatus" ] = "Read from cache";
|
477 |
+
} else {
|
478 |
+
$dataLayer[ "weatherDataStatus" ] = "GTM4WP session active but no weather data in cache (" . $gtm4wp_sessionid . ")";
|
479 |
+
}
|
480 |
+
}
|
481 |
+
|
482 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
|
483 |
+
$geodata = get_transient( 'gtm4wp-geodata-'.$gtm4wp_sessionid );
|
484 |
+
|
485 |
+
if ( false !== $geodata ) {
|
486 |
+
$dataLayer[ "geoCountryCode" ] = $geodata->country_code;
|
487 |
+
$dataLayer[ "geoCountryName" ] = $geodata->country_name;
|
488 |
+
$dataLayer[ "geoRegionCode" ] = $geodata->region_code;
|
489 |
+
$dataLayer[ "geoRegionName" ] = $geodata->region_name;
|
490 |
+
$dataLayer[ "geoCity" ] = $geodata->city;
|
491 |
+
$dataLayer[ "geoZipcode" ] = $geodata->zip;
|
492 |
+
$dataLayer[ "geoLatitude" ] = $geodata->latitude;
|
493 |
+
$dataLayer[ "geoLongitude" ] = $geodata->longitude;
|
494 |
+
$dataLayer[ "geoFullGeoData" ] = $geodata;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
return $dataLayer;
|
502 |
+
}
|
503 |
+
|
504 |
+
function gtm4wp_wp_loaded() {
|
505 |
+
global $gtm4wp_options;
|
506 |
+
|
507 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
|
508 |
+
$gtm4wp_sessionid = array_key_exists( "gtm4wp_sessionid", $_COOKIE ) ? $_COOKIE[ "gtm4wp_sessionid" ] : "";
|
509 |
+
// this is needed so that nobody can do a hack by editing our cookie
|
510 |
+
$gtm4wp_sessionid = str_replace( "'", "", trim( basename( $gtm4wp_sessionid ) ) );
|
511 |
+
|
512 |
+
if ( "" === $gtm4wp_sessionid ) {
|
513 |
+
$gtm4wp_sessionid = substr( md5( date( "Ymd_His" ).rand() ), 0, 20 );
|
514 |
+
setcookie( "gtm4wp_sessionid", $gtm4wp_sessionid, time()+(60*60*24*365*2) );
|
515 |
+
}
|
516 |
+
|
517 |
+
$geodata = get_transient( 'gtm4wp-geodata-'.$gtm4wp_sessionid );
|
518 |
+
|
519 |
+
if ( false === $geodata ) {
|
520 |
+
$gtm4wp_geodata = @wp_remote_get( sprintf( 'http://api.ipstack.com/%s?access_key=%s&format=1', $_SERVER['REMOTE_ADDR'], $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEOAPI ] ) );
|
521 |
+
|
522 |
+
if ( is_array( $gtm4wp_geodata ) && ( 200 == $gtm4wp_geodata[ "response" ][ "code" ] ) ) {
|
523 |
+
$gtm4wp_geodata = @json_decode( $gtm4wp_geodata[ "body" ] );
|
524 |
+
|
525 |
+
if ( is_object( $gtm4wp_geodata ) ) {
|
526 |
+
set_transient( 'gtm4wp-geodata-'.$gtm4wp_sessionid, $gtm4wp_geodata, 60 * 60 );
|
527 |
+
|
528 |
+
$weatherdata = get_transient( 'gtm4wp-weatherdata-'.$gtm4wp_sessionid );
|
529 |
+
if ( false === $weatherdata) {
|
530 |
+
|
531 |
+
$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') );
|
532 |
+
|
533 |
+
if ( is_array( $weatherdata ) && ( 200 == $weatherdata[ "response" ][ "code" ] ) ) {
|
534 |
+
$weatherdata = @json_decode( $weatherdata[ "body" ] );
|
535 |
+
|
536 |
+
if ( is_object( $weatherdata ) ) {
|
537 |
+
set_transient( 'gtm4wp-weatherdata-'.$gtm4wp_sessionid, $weatherdata, 60 * 60 );
|
538 |
+
setcookie( "gtm4wp_last_weatherstatus", "Weather data loaded." );
|
539 |
+
} else {
|
540 |
+
setcookie( "gtm4wp_last_weatherstatus", "Openweathermap.org did not return processable data: " . var_dump( $weatherdata, true ) );
|
541 |
+
}
|
542 |
+
} else {
|
543 |
+
if ( is_wp_error( $weatherdata ) ) {
|
544 |
+
setcookie( "gtm4wp_last_weatherstatus", "Openweathermap.org request error: " . $weatherdata->get_error_message() );
|
545 |
+
} else {
|
546 |
+
setcookie( "gtm4wp_last_weatherstatus", "Openweathermap.org returned status code: " . $weatherdata[ "response" ][ "code" ] );
|
547 |
+
}
|
548 |
+
}
|
549 |
+
}
|
550 |
+
} else {
|
551 |
+
setcookie( "gtm4wp_last_weatherstatus", "freegeoip.net did not return lat-lng data: " . var_dump( $gtm4wp_geodata, true ) );
|
552 |
+
}
|
553 |
+
} else {
|
554 |
+
if ( is_wp_error( $gtm4wp_geodata ) ) {
|
555 |
+
setcookie( "gtm4wp_last_weatherstatus", "freegeoip.net request error: " . $gtm4wp_geodata->get_error_message() );
|
556 |
+
} else {
|
557 |
+
setcookie( "gtm4wp_last_weatherstatus", "freegeoip.net returned status code: " . $gtm4wp_geodata[ "response" ][ "code" ] );
|
558 |
+
}
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
}
|
563 |
+
|
564 |
+
function gtm4wp_get_the_gtm_tag() {
|
565 |
+
global $gtm4wp_options, $gtm4wp_datalayer_name, $gtm4wp_container_code_written;
|
566 |
+
|
567 |
+
$_gtm_tag = '
|
568 |
+
<!-- Google Tag Manager (noscript) -->';
|
569 |
+
|
570 |
+
if ( GTM4WP_PLACEMENT_OFF == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) {
|
571 |
+
$gtm4wp_container_code_written = true;
|
572 |
+
}
|
573 |
+
|
574 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != "" ) && ( ! $gtm4wp_container_code_written ) ) {
|
575 |
+
$_gtm_codes = explode( ",", str_replace( array(";"," "), array(",",""), $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) );
|
576 |
+
|
577 |
+
if ( ("" != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ]) && ("" != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ]) ) {
|
578 |
+
$_gtm_env = ">m_auth=" . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] . ">m_preview=" . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] . ">m_cookies_win=x";
|
579 |
+
} else {
|
580 |
+
$_gtm_env = '';
|
581 |
+
}
|
582 |
+
|
583 |
+
foreach( $_gtm_codes as $one_gtm_code ) {
|
584 |
+
$_gtm_tag .= '
|
585 |
+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' . $one_gtm_code . $_gtm_env . '"
|
586 |
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>';
|
587 |
+
}
|
588 |
+
|
589 |
+
$_gtm_tag .= '
|
590 |
+
<!-- End Google Tag Manager (noscript) -->';
|
591 |
+
|
592 |
+
$_gtm_tag = apply_filters( GTM4WP_WPFILTER_GETTHEGTMTAG, $_gtm_tag );
|
593 |
+
$gtm4wp_container_code_written = true;
|
594 |
+
}
|
595 |
+
|
596 |
+
return $_gtm_tag;
|
597 |
+
}
|
598 |
+
|
599 |
+
function gtm4wp_the_gtm_tag() {
|
600 |
+
echo gtm4wp_get_the_gtm_tag();
|
601 |
+
}
|
602 |
+
|
603 |
+
function gtm4wp_enqueue_scripts() {
|
604 |
+
global $gtm4wp_options, $gtp4wp_plugin_url;
|
605 |
+
|
606 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_OUTBOUND ] ) {
|
607 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_OUTBOUND, false);
|
608 |
+
wp_enqueue_script( "gtm4wp-outbound-click-tracker", $gtp4wp_plugin_url . "js/gtm4wp-outbound-click-tracker.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
609 |
+
}
|
610 |
+
|
611 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DOWNLOADS ] ) {
|
612 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_DOWNLOADS, false);
|
613 |
+
wp_enqueue_script( "gtm4wp-download-tracker", $gtp4wp_plugin_url . "js/gtm4wp-download-tracker.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
614 |
+
}
|
615 |
+
|
616 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_EMAILCLICKS ] ) {
|
617 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_EMAILCLICKS, false);
|
618 |
+
wp_enqueue_script( "gtm4wp-email-link-tracker", $gtp4wp_plugin_url . "js/gtm4wp-email-link-tracker.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
619 |
+
}
|
620 |
+
|
621 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WPCF7 ] ) {
|
622 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_INTEGRATE_WPCF7, false);
|
623 |
+
wp_enqueue_script( "gtm4wp-contact-form-7-tracker", $gtp4wp_plugin_url . "js/gtm4wp-contact-form-7-tracker.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
624 |
+
}
|
625 |
+
|
626 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_FORMMOVE ] ) {
|
627 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_FORMMOVE, false);
|
628 |
+
wp_enqueue_script( "gtm4wp-form-move-tracker", $gtp4wp_plugin_url . "js/gtm4wp-form-move-tracker.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
629 |
+
}
|
630 |
+
|
631 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOCIAL ] ) {
|
632 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_EVENTS_SOCIAL, false);
|
633 |
+
wp_enqueue_script( "gtm4wp-social-actions", $gtp4wp_plugin_url . "js/gtm4wp-social-tracker.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
634 |
+
}
|
635 |
+
|
636 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_YOUTUBE ] ) {
|
637 |
+
require_once( dirname( __FILE__ ) . "/../integration/youtube.php" );
|
638 |
+
}
|
639 |
+
|
640 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_VIMEO ] ) {
|
641 |
+
require_once( dirname( __FILE__ ) . "/../integration/vimeo.php" );
|
642 |
+
}
|
643 |
+
|
644 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_SOUNDCLOUD ] ) {
|
645 |
+
require_once( dirname( __FILE__ ) . "/../integration/soundcloud.php" );
|
646 |
+
}
|
647 |
+
|
648 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
649 |
+
$in_footer = apply_filters( 'gtm4wp_' . GTM4WP_OPTION_SCROLLER_ENABLED, false);
|
650 |
+
wp_enqueue_script( "gtm4wp-scroll-tracking", $gtp4wp_plugin_url . "js/analytics-talk-content-tracking.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
651 |
+
}
|
652 |
+
}
|
653 |
+
|
654 |
+
function gtm4wp_wp_footer() {
|
655 |
+
global $gtm4wp_options;
|
656 |
+
|
657 |
+
if ( GTM4WP_PLACEMENT_FOOTER == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) {
|
658 |
+
gtm4wp_the_gtm_tag();
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
function gtm4wp_wp_body_open() {
|
663 |
+
global $gtm4wp_options;
|
664 |
+
|
665 |
+
if ( ( GTM4WP_PLACEMENT_BODYOPEN == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) || ( GTM4WP_PLACEMENT_BODYOPEN_AUTO == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) ) {
|
666 |
+
gtm4wp_the_gtm_tag();
|
667 |
+
}
|
668 |
+
}
|
669 |
+
|
670 |
+
function gtm4wp_filter_visitor_keys( $dataLayer ) {
|
671 |
+
foreach( $dataLayer as $dl_key => $dl_value ) {
|
672 |
+
if ( strpos( $dl_key, "visitor" ) !== false ) {
|
673 |
+
unset( $dataLayer[ $dl_key ] );
|
674 |
+
}
|
675 |
+
}
|
676 |
+
|
677 |
+
return $dataLayer;
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* GTM4WP global JS variables Wordpress filter
|
682 |
+
*
|
683 |
+
* @author Vincent Koc <https://github.com/koconder/>
|
684 |
+
* @link https://github.com/duracelltomi/gtm4wp/issues/34
|
685 |
+
* @return mixed returns the
|
686 |
+
*/
|
687 |
+
function gtm4wp_add_global_vars( $vars, $return = false ){
|
688 |
+
if(!$return){
|
689 |
+
if(function_exists($vars)){
|
690 |
+
$vars = $vars();
|
691 |
+
}
|
692 |
+
$GLOBALS[ "gtm4wp_datalayer_globalvars" ] = $GLOBALS[ "gtm4wp_datalayer_globalvars" ].' '.$vars;
|
693 |
+
}
|
694 |
+
return $GLOBALS[ "gtm4wp_datalayer_globalvars" ];
|
695 |
+
}
|
696 |
+
|
697 |
+
function gtm4wp_wp_header_top( $echo = true ) {
|
698 |
+
global $gtm4wp_options, $gtm4wp_datalayer_name;
|
699 |
+
|
700 |
+
$_gtm_top_content = '
|
701 |
+
<!-- Google Tag Manager for WordPress by gtm4wp.com -->
|
702 |
+
<script data-cfasync="false" type="text/javascript">//<![CDATA[
|
703 |
+
var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
|
704 |
+
var ' . $gtm4wp_datalayer_name . ' = ' . $gtm4wp_datalayer_name . ' || [];';
|
705 |
+
|
706 |
+
// Load in the global variables from gtm4wp_add_global_vars / GTM4WP_WPACTION_ADDGLOBALVARS filter
|
707 |
+
$_gtm_top_content .= apply_filters(GTM4WP_WPACTION_ADDGLOBALVARS, '', true);
|
708 |
+
|
709 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
710 |
+
$_gtm_top_content .= '
|
711 |
+
|
712 |
+
var gtm4wp_scrollerscript_debugmode = ' . ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_DEBUGMODE ] ? 'true' : 'false' ) . ';
|
713 |
+
var gtm4wp_scrollerscript_callbacktime = ' . (int) $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_CALLBACKTIME ] . ';
|
714 |
+
var gtm4wp_scrollerscript_readerlocation = ' . (int) $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_DISTANCE ] . ';
|
715 |
+
var gtm4wp_scrollerscript_contentelementid = "' . $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_CONTENTID ] . '";
|
716 |
+
var gtm4wp_scrollerscript_scannertime = ' . (int) $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_READERTIME ] . ';';
|
717 |
+
}
|
718 |
+
|
719 |
+
$_gtm_top_content .= '
|
720 |
+
//]]>
|
721 |
+
</script>
|
722 |
+
<!-- End Google Tag Manager for WordPress by gtm4wp.com -->';
|
723 |
+
|
724 |
+
if( !gtm4wp_amp_running() ) {
|
725 |
+
if ( $echo ) {
|
726 |
+
echo $_gtm_top_content;
|
727 |
+
} else {
|
728 |
+
return $_gtm_top_content;
|
729 |
+
}
|
730 |
+
}
|
731 |
+
}
|
732 |
+
|
733 |
+
function gtm4wp_wp_header_begin( $echo = true ) {
|
734 |
+
global $gtm4wp_datalayer_name, $gtm4wp_datalayer_json, $gtm4wp_options;
|
735 |
+
|
736 |
+
$_gtm_header_content = '
|
737 |
+
<!-- Google Tag Manager for WordPress by gtm4wp.com -->
|
738 |
+
<script data-cfasync="false" type="text/javascript">//<![CDATA[';
|
739 |
+
|
740 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != "" ) {
|
741 |
+
$gtm4wp_datalayer_data = array();
|
742 |
+
$gtm4wp_datalayer_data = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_DATALAYER, $gtm4wp_datalayer_data );
|
743 |
+
|
744 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_REMARKETING ] ) {
|
745 |
+
// add adwords remarketing tags as suggested here:
|
746 |
+
// https://support.google.com/tagmanager/answer/3002580?hl=en
|
747 |
+
|
748 |
+
add_filter( GTM4WP_WPFILTER_COMPILE_REMARKTING, "gtm4wp_filter_visitor_keys" );
|
749 |
+
$gtm4wp_remarketing_tags = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_REMARKTING, $gtm4wp_datalayer_data );
|
750 |
+
|
751 |
+
$_gtm_header_content .= 'var google_tag_params = ';
|
752 |
+
$_gtm_header_content .= json_encode( $gtm4wp_remarketing_tags );
|
753 |
+
$_gtm_header_content .= ';';
|
754 |
+
$gtm4wp_datalayer_data["google_tag_params"] = "-~-window.google_tag_params-~-";
|
755 |
+
}
|
756 |
+
|
757 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DOWNLOADS ] ) {
|
758 |
+
$_gtm_header_content .= '
|
759 |
+
jQuery( function() {
|
760 |
+
gtm4wp_track_downloads( "' . str_replace( '"', '', $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DWLEXT ] ) . '" );
|
761 |
+
});';
|
762 |
+
}
|
763 |
+
|
764 |
+
if ( version_compare( PHP_VERSION, '5.4.0' ) >= 0 ) {
|
765 |
+
$gtm4wp_datalayer_json = json_encode( $gtm4wp_datalayer_data, JSON_UNESCAPED_UNICODE );
|
766 |
+
} else {
|
767 |
+
$gtm4wp_datalayer_json = json_encode( $gtm4wp_datalayer_data );
|
768 |
+
}
|
769 |
+
|
770 |
+
// Clean up and then push datalayer to AMP
|
771 |
+
$gtm4wp_datalayer_json = str_replace(
|
772 |
+
array( '"-~-', '-~-"' ),
|
773 |
+
array( "", "" ),
|
774 |
+
str_replace( "", "-", $gtm4wp_datalayer_json )
|
775 |
+
);
|
776 |
+
|
777 |
+
$_gtm_header_content .= '
|
778 |
+
' . $gtm4wp_datalayer_name . '.push(' . $gtm4wp_datalayer_json . ');';
|
779 |
+
}
|
780 |
+
|
781 |
+
$_gtm_header_content .= '//]]>
|
782 |
+
</script>';
|
783 |
+
|
784 |
+
$_gtm_header_content .= apply_filters( GTM4WP_WPFILTER_AFTER_DATALAYER, "" );
|
785 |
+
|
786 |
+
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != "" ) && ( GTM4WP_PLACEMENT_OFF != $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) ) {
|
787 |
+
$_gtm_codes = explode( ",", str_replace( array(";"," "), array(",",""), $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) );
|
788 |
+
|
789 |
+
$_gtm_tag = '';
|
790 |
+
foreach( $_gtm_codes as $one_gtm_code ) {
|
791 |
+
if ( ("" != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ]) && ("" != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ]) ) {
|
792 |
+
$_gtm_env = "+'>m_auth=" . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] . ">m_preview=" . $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] . ">m_cookies_win=x'";
|
793 |
+
} else {
|
794 |
+
$_gtm_env = '';
|
795 |
+
}
|
796 |
+
|
797 |
+
$_gtm_tag .= '
|
798 |
+
<script data-cfasync="false">//<![CDATA[
|
799 |
+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
|
800 |
+
new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
|
801 |
+
j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
802 |
+
\'//www.googletagmanager.com/gtm.\''.'+\'js?id=\'+i+dl' . $_gtm_env . ';f.parentNode.insertBefore(j,f);
|
803 |
+
})(window,document,\'script\',\'' . $gtm4wp_datalayer_name . '\',\'' . $one_gtm_code . '\');//]]>
|
804 |
+
</script>';
|
805 |
+
}
|
806 |
+
|
807 |
+
$_gtm_tag .= '
|
808 |
+
<!-- End Google Tag Manager -->';
|
809 |
+
|
810 |
+
$_gtm_tag = apply_filters( GTM4WP_WPFILTER_GETTHEGTMTAG, $_gtm_tag );
|
811 |
+
$_gtm_header_content .= $_gtm_tag;
|
812 |
+
}
|
813 |
+
|
814 |
+
$_gtm_header_content .= '
|
815 |
+
<!-- End Google Tag Manager for WordPress by gtm4wp.com -->';
|
816 |
+
|
817 |
+
if ( !gtm4wp_amp_running() ) {
|
818 |
+
if ( $echo ) {
|
819 |
+
echo $_gtm_header_content;
|
820 |
+
} else {
|
821 |
+
return $_gtm_header_content;
|
822 |
+
}
|
823 |
+
}
|
824 |
+
}
|
825 |
+
|
826 |
+
function gtm4wp_body_class( $classes ) {
|
827 |
+
global $gtm4wp_options;
|
828 |
+
|
829 |
+
// solution is based on the code of Yaniv Friedensohn
|
830 |
+
// http://www.affectivia.com/blog/placing-the-google-tag-manager-in-wordpress-after-the-body-tag/
|
831 |
+
if ( GTM4WP_PLACEMENT_BODYOPEN_AUTO == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) {
|
832 |
+
$classes[] = '">' . gtm4wp_get_the_gtm_tag() . '<br style="display:none;';
|
833 |
+
}
|
834 |
+
|
835 |
+
return $classes;
|
836 |
+
}
|
837 |
+
|
838 |
+
function gtm4wp_wp_login() {
|
839 |
+
setcookie( 'gtm4wp_user_logged_in', "1", 0, "/" );
|
840 |
+
}
|
841 |
+
|
842 |
+
function gtm4wp_user_register() {
|
843 |
+
setcookie( 'gtm4wp_user_registered', "1", 0, "/" );
|
844 |
+
}
|
845 |
+
|
846 |
+
function gtm4wp_user_reg_login_script() {
|
847 |
+
global $gtp4wp_plugin_url;
|
848 |
+
|
849 |
+
$in_footer = apply_filters( 'gtm4wp_user_reg_login_script', true);
|
850 |
+
wp_enqueue_script( "gtm4wp-user-reg-login-script", $gtp4wp_plugin_url . "js/gtm4wp-users.js", array( "jquery" ), GTM4WP_VERSION, $in_footer );
|
851 |
+
}
|
852 |
+
|
853 |
+
function gtm4wp_rocket_excluded_inline_js_content( $pattern ) {
|
854 |
+
$pattern[] = "dataLayer";
|
855 |
+
$pattern[] = "gtm4wp";
|
856 |
+
|
857 |
+
return $pattern;
|
858 |
+
}
|
859 |
+
|
860 |
+
add_action( "wp_enqueue_scripts", "gtm4wp_enqueue_scripts" );
|
861 |
+
$gtm4wp_header_begin_prior = 10;
|
862 |
+
if ( isset( $GLOBALS[ "gtm4wp_options" ] ) && $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_LOADEARLY ] ) {
|
863 |
+
$gtm4wp_header_begin_prior = 2;
|
864 |
+
}
|
865 |
+
add_action( "wp_head", "gtm4wp_wp_header_begin", $gtm4wp_header_begin_prior, 0 );
|
866 |
+
add_action( "wp_head", "gtm4wp_wp_header_top", 1, 0 );
|
867 |
+
add_action( "wp_footer", "gtm4wp_wp_footer" );
|
868 |
+
add_action( "wp_loaded", "gtm4wp_wp_loaded" );
|
869 |
+
add_filter( "body_class", "gtm4wp_body_class", 10000 );
|
870 |
+
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtm4wp_add_basic_datalayer_data" );
|
871 |
+
|
872 |
+
// to be able to easily migrate from other Google Tag Manager plugins
|
873 |
+
add_action( "body_open", "gtm4wp_wp_body_open" );
|
874 |
+
|
875 |
+
// compatibility with existing themes that natively support code injection after opening body tag
|
876 |
+
add_action( "genesis_before", "gtm4wp_wp_body_open" ); // Genisis theme
|
877 |
+
add_action( "generate_before_header", "gtm4wp_wp_body_open", 0 ); // GeneratePress theme
|
878 |
+
add_action( "elementor/page_templates/canvas/before_content", "gtm4wp_wp_body_open" ); // Elementor
|
879 |
+
add_filter( "rocket_excluded_inline_js_content", "gtm4wp_rocket_excluded_inline_js_content" ); // WP Rocket
|
880 |
+
if ( isset( $GLOBALS[ "gtm4wp_options" ] ) && ( $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] || $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] )
|
881 |
+
&& isset ( $GLOBALS["woocommerce"] ) ) {
|
882 |
+
require_once( dirname( __FILE__ ) . "/../integration/woocommerce.php" );
|
883 |
+
}
|
884 |
+
|
885 |
+
if ( isset( $GLOBALS[ "gtm4wp_options" ] ) && ( $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ] != "" ) ) {
|
886 |
+
require_once( dirname( __FILE__ ) . "/../integration/google-optimize.php" );
|
887 |
+
}
|
888 |
+
|
889 |
+
if ( isset( $GLOBALS[ "gtm4wp_options" ] ) && ( $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_EVENTS_USERLOGIN ] ) ) {
|
890 |
+
add_action( "wp_login", "gtm4wp_wp_login" );
|
891 |
+
add_action( "wp_enqueue_scripts", "gtm4wp_user_reg_login_script" );
|
892 |
+
}
|
893 |
+
|
894 |
+
if ( isset( $GLOBALS[ "gtm4wp_options" ] ) && ( $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_EVENTS_NEWUSERREG ] ) ) {
|
895 |
+
add_action( "user_register", "gtm4wp_user_register" );
|
896 |
+
add_action( "wp_enqueue_scripts", "gtm4wp_user_reg_login_script" );
|
897 |
+
}
|
readme.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
=== DuracellTomi's 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, adwords remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel
|
5 |
Requires at least: 3.4.0
|
6 |
-
Requires PHP: 5.
|
7 |
-
Tested up to: 4.9.
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl.html
|
11 |
|
12 |
-
The first Google Tag Manager plugin for WordPress with business goals in mind.
|
13 |
|
14 |
== Description ==
|
15 |
|
@@ -22,10 +22,12 @@ Multiple containers are also supported!
|
|
22 |
The plugin complements your GTM setup by pushing page meta data and user information into the so called data layer.
|
23 |
Google's official help pages includes [more details about the data layer](https://developers.google.com/tag-manager/devguide#datalayer).
|
24 |
|
25 |
-
|
26 |
-
PHP 5.4 or newer is recommended.**
|
27 |
|
28 |
-
|
|
|
|
|
|
|
29 |
your hosting provider for support.
|
30 |
|
31 |
= GTM container code placement =
|
@@ -90,7 +92,8 @@ http://openweathermap.org/price
|
|
90 |
|
91 |
An (free) API key from OpenWeatherMap is required for this feature to work.
|
92 |
|
93 |
-
|
|
|
94 |
|
95 |
= Media player events =
|
96 |
|
@@ -255,6 +258,33 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
|
|
255 |
|
256 |
== Changelog ==
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
= 1.8.1 =
|
259 |
|
260 |
* Added: new visitorIP data layer variable to support post-GDPR implementations where for example internal traffic exclusion has to be made inside the browser
|
@@ -534,6 +564,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
|
|
534 |
|
535 |
== Upgrade Notice ==
|
536 |
|
|
|
|
|
|
|
|
|
537 |
= 1.8.1 =
|
538 |
|
539 |
Bugfix version fixing some issues around WooCommerce tracking and GTM environments. Also adds IP address into the data layer.
|
1 |
=== DuracellTomi's 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
|
5 |
Requires at least: 3.4.0
|
6 |
+
Requires PHP: 5.6
|
7 |
+
Tested up to: 4.9.8
|
8 |
+
Stable tag: 1.9
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl.html
|
11 |
|
12 |
+
The first Google Tag Manager plugin for WordPress with business goals in mind. Includes full support for Google Optimize as well.
|
13 |
|
14 |
== Description ==
|
15 |
|
22 |
The plugin complements your GTM setup by pushing page meta data and user information into the so called data layer.
|
23 |
Google's official help pages includes [more details about the data layer](https://developers.google.com/tag-manager/devguide#datalayer).
|
24 |
|
25 |
+
You can also add your Google Optimize container with the [recommended code setup](https://support.google.com/optimize/answer/7359264?hl=en)
|
|
|
26 |
|
27 |
+
**Some parts of the plugin require PHP 5.6 newer.
|
28 |
+
PHP 7.0 or newer is recommended.**
|
29 |
+
|
30 |
+
Please note that PHP 5.6 is nearing its end of life cycle thus it is recommended to upgrade. If you are not sure which version you are using, please contact
|
31 |
your hosting provider for support.
|
32 |
|
33 |
= GTM container code placement =
|
92 |
|
93 |
An (free) API key from OpenWeatherMap is required for this feature to work.
|
94 |
|
95 |
+
ipstack.com is used to determine the site visitor's location. A (free) API key from IPStack.com is required for this feature to work:
|
96 |
+
https://ipstack.com/product
|
97 |
|
98 |
= Media player events =
|
99 |
|
258 |
|
259 |
== Changelog ==
|
260 |
|
261 |
+
= 1.9 =
|
262 |
+
|
263 |
+
* Added: initial support for AMP plugin from Automattic (thx koconder for the contribution!)
|
264 |
+
* Added: option to remove tax from revenue data on order received page of WooCommerce
|
265 |
+
* Added: WooCommerce enhanced ecommerce datasets now include stock levels
|
266 |
+
* Added: new productIsVariable data layer variable is set to 1 on variable WooCommerce product pages
|
267 |
+
* Added: product impressions can now be split into multiple chunks to prevent data loss on large product category and site home pages (thx Tim Zook for the contribution!)
|
268 |
+
* IMPORTANT! You will need to update your GTM setup, please read the new Step 9 section of the [setup tutorial page](https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking).
|
269 |
+
* Added: you can now disable flagging of WooCommerce orders as being already tracked once. In same cases (with iDeal for example) you may need this to make purchase tracking to work.
|
270 |
+
* Added: uninstalling the plugin will now remove configured plugin options from database
|
271 |
+
* Added: new advanced plugin option: data layer variable visitorDoNotTrack will include 1 if the user has set the [do not track flag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/DNT) in his/her browser
|
272 |
+
* Added: new data layer event when a user has logged in on the frontend: gtm4wp.userLoggedIn
|
273 |
+
* Added: new data layer event when a new user has registered on the frontend: gtm4wp.userRegistered
|
274 |
+
* Added: new advanced plugin option: move data layer declaration and Google Tag Manager container as close as possible to the beginning of the HTML document
|
275 |
+
* Added: better WP Rocket support
|
276 |
+
* Updated: Full Google Optimize support. Now the plugin can load your Google Optimize container with the [recommended code placement](https://support.google.com/optimize/answer/7359264?hl=en)
|
277 |
+
* Updated: moved most of the inline JavaScript codes into separate .js files which should help cache plugins to do their job much better when my plugin is active
|
278 |
+
* Fixed: wrong ecomm_pagetype on product search result pages
|
279 |
+
* Fixed: PHP notice in some cases when geo data was not loaded properly
|
280 |
+
* Fixed / Added: freegeoip.net was rebranded to ipstack.com and an API key is needed now even for free usage. You can now add your API key so that weather data and geo data can be added into the data layer
|
281 |
+
* Warning: some plugin features will be remove from v1.10, most of them can be tracked now using pure Google Tag Manager triggers:
|
282 |
+
* Social actions
|
283 |
+
* Outbound link click events
|
284 |
+
* Download click events
|
285 |
+
* Email click events
|
286 |
+
* Warning: PHP 5.6 is now the minimum recommended version to use this plugin. I advise to move to PHP 7.x
|
287 |
+
|
288 |
= 1.8.1 =
|
289 |
|
290 |
* Added: new visitorIP data layer variable to support post-GDPR implementations where for example internal traffic exclusion has to be made inside the browser
|
564 |
|
565 |
== Upgrade Notice ==
|
566 |
|
567 |
+
= 1.9 =
|
568 |
+
|
569 |
+
New AMP GTM support, full Google Optimize support, lots of WooCommerce tracking improvements.
|
570 |
+
|
571 |
= 1.8.1 =
|
572 |
|
573 |
Bugfix version fixing some issues around WooCommerce tracking and GTM environments. Also adds IP address into the data layer.
|
uninstall.php
ADDED
@@ -0,0 +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( dirname( __FILE__ ) . "/common/readoptions.php" );
|
8 |
+
|
9 |
+
delete_option( GTM4WP_OPTIONS );
|