@@ -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 ); ?> ',
0 commit comments