Skip to content

Commit

Permalink
fix: Better check if gtag is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimple committed Jan 18, 2024
1 parent 1ce9dee commit 88c830d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions class/class-edu-google.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function track_list_course_view( $courses ) {

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

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

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

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

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

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

if ( count( $order_rows ) > 0 ) {
?>
<script type="text/javascript">if (gtag) {
<script type="text/javascript">if (typeof gtag != 'undefined') {
gtag('event', 'purchase', {
'transaction_id': '<?php echo esc_js( $transaction_id ); ?>',
'currency': '<?php echo esc_js( $currency ); ?>',
Expand Down
2 changes: 1 addition & 1 deletion eduadmin-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Plugin URI: https://www.eduadmin.se
* Description: This plugin adds support for Google Analytics / Tag Manager to your EduAdmin plugin (WordPress only, not the course portal).
* Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
* Version: 1.1.1
* Version: 1.1.2
* GitHub Plugin URI: multinetinteractive/eduadmin-google
* GitHub Plugin URI: https://github.com/multinetinteractive/eduadmin-google
* Requires at least: 5.8
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eduadmin-analytics",
"version": "1.1.1",
"version": "1.1.2",
"description": "This plugin adds support for Google Analytics / Tag Manager to your EduAdmin plugin (WordPress only, not the course portal).",
"repository": "https://github.com/MultinetInteractive/eduadmin-google.git",
"author": "Chris Gårdenberg <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
- Requires at least: 5.8
- Tested up to: 6.4
- Stable tag: 1.1.1
- Stable tag: 1.1.2
- Requires PHP: 7.0
- License: GPL3
- License-URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: mnchga
Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
Requires at least: 5.8
Tested up to: 6.4
Stable tag: 1.1.1
Stable tag: 1.1.2
Requires PHP: 7.0
License: GPL3
License-URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Expand Down

0 comments on commit 88c830d

Please sign in to comment.