Skip to content

Commit 88c830d

Browse files
author
Chris Gårdenberg
committed
fix: Better check if gtag is defined
1 parent 1ce9dee commit 88c830d

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

class/class-edu-google.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function track_list_course_view( $courses ) {
7878

7979
if ( count( $gtag_items ) > 0 ) {
8080
?>
81-
<script type="text/javascript">if (gtag) {
81+
<script type="text/javascript">if (typeof gtag != 'undefined') {
8282
gtag('event', 'view_item_list', {
8383
'item_list_id': 'course_list',
8484
'item_list_name': 'Course list',
@@ -113,7 +113,7 @@ public function track_list_event_view( $events ) {
113113

114114
if ( count( $gtag_items ) > 0 ) {
115115
?>
116-
<script type="text/javascript">if (gtag) {
116+
<script type="text/javascript">if (typeof gtag != 'undefined') {
117117
gtag('event', 'view_item_list', {
118118
'item_list_id': 'event_list',
119119
'item_list_name': 'Event list',
@@ -149,7 +149,7 @@ public function track_detail_view( $course_template ) {
149149

150150
if ( count( $gtag_items ) > 0 ) {
151151
?>
152-
<script type="text/javascript">if (gtag) {
152+
<script type="text/javascript">if (typeof gtag != 'undefined') {
153153
gtag('event', 'view_item', {
154154
'currency': '<?php echo esc_js( $currency ); ?>',
155155
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });
@@ -180,7 +180,7 @@ public function track_programme_detail_view( $programme ) {
180180

181181
if ( count( $gtag_items ) > 0 ) {
182182
?>
183-
<script type="text/javascript">if (gtag) {
183+
<script type="text/javascript">if (typeof gtag != 'undefined') {
184184
gtag('event', 'view_item', {
185185
'currency': '<?php echo esc_js( $currency ); ?>',
186186
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });
@@ -215,7 +215,7 @@ public function track_booking_view( $course_template ) {
215215

216216
if ( count( $gtag_items ) > 0 ) {
217217
?>
218-
<script type="text/javascript">if (gtag) {
218+
<script type="text/javascript">if (typeof gtag != 'undefined') {
219219
gtag('event', 'begin_checkout', {
220220
'currency': '<?php echo esc_js( $currency ); ?>',
221221
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });
@@ -246,7 +246,7 @@ public function track_programme_booking_view( $programme ) {
246246

247247
if ( count( $gtag_items ) > 0 ) {
248248
?>
249-
<script type="text/javascript">if (gtag) {
249+
<script type="text/javascript">if (typeof gtag != 'undefined') {
250250
gtag('event', 'begin_checkout', {
251251
'currency': '<?php echo esc_js( $currency ); ?>',
252252
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });
@@ -286,7 +286,7 @@ public function track_booking_completed( $booking_info ) {
286286

287287
if ( count( $order_rows ) > 0 ) {
288288
?>
289-
<script type="text/javascript">if (gtag) {
289+
<script type="text/javascript">if (typeof gtag != 'undefined') {
290290
gtag('event', 'purchase', {
291291
'transaction_id': '<?php echo esc_js( $transaction_id ); ?>',
292292
'currency': '<?php echo esc_js( $currency ); ?>',

eduadmin-analytics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Plugin URI: https://www.eduadmin.se
77
* Description: This plugin adds support for Google Analytics / Tag Manager to your EduAdmin plugin (WordPress only, not the course portal).
88
* Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
9-
* Version: 1.1.1
9+
* Version: 1.1.2
1010
* GitHub Plugin URI: multinetinteractive/eduadmin-google
1111
* GitHub Plugin URI: https://github.com/multinetinteractive/eduadmin-google
1212
* Requires at least: 5.8

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eduadmin-analytics",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "This plugin adds support for Google Analytics / Tag Manager to your EduAdmin plugin (WordPress only, not the course portal).",
55
"repository": "https://github.com/MultinetInteractive/eduadmin-google.git",
66
"author": "Chris Gårdenberg <chga@multinet.se>",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
44
- Requires at least: 5.8
55
- Tested up to: 6.4
6-
- Stable tag: 1.1.1
6+
- Stable tag: 1.1.2
77
- Requires PHP: 7.0
88
- License: GPL3
99
- License-URI: https://www.gnu.org/licenses/gpl-3.0.en.html

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: mnchga
33
Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
44
Requires at least: 5.8
55
Tested up to: 6.4
6-
Stable tag: 1.1.1
6+
Stable tag: 1.1.2
77
Requires PHP: 7.0
88
License: GPL3
99
License-URI: https://www.gnu.org/licenses/gpl-3.0.en.html

0 commit comments

Comments
 (0)