Pixel Manager for WooCommerce – Track Google Analytics, Google Ads, Facebook and more - Version 1.3.6

Version Description

  • New: WordPress 4.8 compatibility update
  • Tweak: Minor text tweak.
Download this release

Release Info

Developer alekv
Plugin Icon 128x128 Pixel Manager for WooCommerce – Track Google Analytics, Google Ads, Facebook and more
Version 1.3.6
Comparing to
See all releases

Code changes from version 1.2.2 to 1.3.6

images/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
images/wgact-icon-256x256.png ADDED
Binary file
images/wgdr-icon-256x256.png ADDED
Binary file
includes/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
includes/rating.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
+
7
+ ?>
8
+
9
+ <div class="rate">
10
+ <div class="rating-stars">
11
+ <a href="//wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=1#postform"
12
+ data-rating="1" title="" target="_blank">
13
+ <span class="dashicons dashicons-star-filled" style="color:#ffb900 !important;"></span></a>
14
+ <a href="//wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=2#postform"
15
+ data-rating="2" title="" target="_blank">
16
+ <span class="dashicons dashicons-star-filled" style="color:#ffb900 !important;"></span></a>
17
+ <a href="//wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=3#postform"
18
+ data-rating="3" title="" target="_blank">
19
+ <span class="dashicons dashicons-star-filled" style="color:#ffb900 !important;"></span></a>
20
+ <a href="//wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=4#postform"
21
+ data-rating="4" title="" target="_blank">
22
+ <span class="dashicons dashicons-star-filled" style="color:#ffb900 !important;"></span></a>
23
+ <a href="//wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=5#postform"
24
+ data-rating="5" title="" target="_blank">
25
+ <span class="dashicons dashicons-star-filled" style="color:#ffb900 !important;"></span></a>
26
+ </div>
27
+ <input type="hidden" name="rating" id="rating" value="5">
28
+ <input type="hidden" name="review_topic_slug" value="woocommerce-google-adwords-conversion-tracking-tag">
29
+ <script>
30
+ jQuery(document).ready(function ($) {
31
+ $('.rating-stars').find('a').hover(
32
+ function () {
33
+ $(this).nextAll('a').children('span').removeClass('dashicons-star-filled').addClass('dashicons-star-empty');
34
+ $(this).prevAll('a').children('span').removeClass('dashicons-star-empty').addClass('dashicons-star-filled');
35
+ $(this).children('span').removeClass('dashicons-star-empty').addClass('dashicons-star-filled');
36
+ }, function () {
37
+ var rating = $('input#rating').val();
38
+ if (rating) {
39
+ var list = $('.rating-stars a');
40
+ list.children('span').removeClass('dashicons-star-filled').addClass('dashicons-star-empty');
41
+ list.slice(0, rating).children('span').removeClass('dashicons-star-empty').addClass('dashicons-star-filled');
42
+ }
43
+ }
44
+ );
45
+ });
46
+ </script>
47
+ </div>
index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
languages/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
  Contributors: alekv
3
  Donate link: http://www.wolfundbaer.ch/donations/
4
- Tags: WooCommerce, Google AdWords, AdWords, conversion, conversion value, conversion tag, conversion value tracking, conversion tracking
5
  Requires at least: 3.1
6
- Tested up to: 4.4.2
7
- Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,15 +12,26 @@ Track the dynamic order value in AdWords from WooCommerce
12
 
13
  == Description ==
14
 
15
- This plugin tracks the value of WooCommerce orders in Google AdWords. With this you can optimize all your AdWords campaings to achieve maximum efficiency.
 
 
 
 
 
 
 
 
 
16
 
17
  <strong>Other plugins</strong>
18
 
19
  If you like this plugin you might like that one too: https://wordpress.org/plugins/woocommerce-google-dynamic-retargeting-tag/
20
 
21
- <strong>Translations</strong>
22
 
23
- Thanks to Adrijana Nikolic from http://webhostinggeeks.com for the translation into Serbian.
 
 
24
 
25
  == Installation ==
26
 
@@ -36,7 +47,20 @@ Thanks to Adrijana Nikolic from http://webhostinggeeks.com for the translation i
36
 
37
  = How do I check if the plugin is working properly? =
38
 
39
- Download the Google Tag Assistant browser plugin. It is a powerful tool to validate all Google tags on your pages.
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  = Where can I report a bug or suggest improvements? =
42
 
@@ -44,9 +68,25 @@ Please post your problem in the WGACT Support forum: http://wordpress.org/suppor
44
  You can send the link to the front page of your shop too if you think it would be of help.
45
 
46
  == Screenshots ==
 
47
 
48
  == Changelog ==
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  = 1.2.2 =
51
  * New: Filter for the conversion value
52
  = 1.2.1 =
1
  === Plugin Name ===
2
  Contributors: alekv
3
  Donate link: http://www.wolfundbaer.ch/donations/
4
+ Tags: woocommerce, woocommerce conversion tracking, google adwords, adwords, conversion, conversion value, conversion tag, conversion pixel, conversion value tracking, conversion tracking, conversion tracking adwords, conversion tracking pixel, conversion tracking script, track conversions, tracking code manager
5
  Requires at least: 3.1
6
+ Tested up to: 4.8
7
+ Stable tag: 1.3.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ This plugin <strong>tracks the value of WooCommerce orders in Google AdWords</strong>. With this you can optimize all your AdWords campaings to achieve maximum efficiency.
16
+
17
+ <strong>Highlights</strong>
18
+
19
+ * Very accurate by preventing duplicate reporting effectively, excluding admins and shop managers from tracking, and not counting failed payments.
20
+ * Very easy to install and maintain.
21
+
22
+ <strong>Requirements</strong>
23
+
24
+ * The payment gateway **must** support on-site payments. If you want to use an off-site payment solution like the free PayPal extension you need to make sure that the visitor is being redirected back to the WooCommerce thankyou page after the successful transaction. Only if the redirection is set up properly and the visitor doesn't stop the redirection, only then the conversion will be counted.
25
 
26
  <strong>Other plugins</strong>
27
 
28
  If you like this plugin you might like that one too: https://wordpress.org/plugins/woocommerce-google-dynamic-retargeting-tag/
29
 
30
+ <strong>Supported languages</strong>
31
 
32
+ * English
33
+ * German
34
+ * Serbian ( by Adrijana Nikolic http://webhostinggeeks.com )
35
 
36
  == Installation ==
37
 
47
 
48
  = How do I check if the plugin is working properly? =
49
 
50
+ 1. Log out of the shop.
51
+ 2. Search for one of your keywords and click on one of your ads.
52
+ 3. Purchase an item from your shop.
53
+ 4. Wait until the conversion shows up in AdWords.
54
+
55
+ With the Google Tag Assistant you will also be able to see the tag fired on the thankyou page.
56
+
57
+ = I get a fatal error and I am running old versions of WordPress and/or WooCommerce. What can I do? =
58
+
59
+ As this is a free plugin we don't support old version of WordPress and WooCommerce. You will have to update your installation.
60
+
61
+ = I am using an offsite payment gateway and the conversions are not being tracked. What can I do? =
62
+
63
+ We don't support if an offsite payment gateway is in use. The reason is that those cases can be complex and time consuming. We don't want to cover this for a free plugin. We do not recommend offsite payment gateways anyway. A visitor can stop the redirection manually which prevents at least some conversions to be tracked. Also offsite payment gateways are generally bad for the conversion rate.
64
 
65
  = Where can I report a bug or suggest improvements? =
66
 
68
  You can send the link to the front page of your shop too if you think it would be of help.
69
 
70
  == Screenshots ==
71
+ 1. Settings page
72
 
73
  == Changelog ==
74
 
75
+ = 1.3.6 =
76
+ * New: WordPress 4.8 compatibility update
77
+ * Tweak: Minor text tweak.
78
+ = 1.3.5 =
79
+ * Fix: Fixed a syntax error that caused issues on some installations.
80
+ = 1.3.4 =
81
+ * Tweak: Added some text output to make debugging for users easier.
82
+ = 1.3.3 =
83
+ * Tweak: Refurbishment of the settings page
84
+ = 1.3.2 =
85
+ * New: Uninstall routine
86
+ = 1.3.1 =
87
+ * New: Keep old deduplication logic in the code as per recommendation by AdWords
88
+ = 1.3.0 =
89
+ * New: AdWords native order ID deduplication variable
90
  = 1.2.2 =
91
  * New: Filter for the conversion value
92
  = 1.2.1 =
uninstall.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uninstall routine for the WGACT plugin
4
+ */
5
+
6
+ // If uninstall is not called from WordPress, exit
7
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
8
+ exit();
9
+ }
10
+
11
+ $option_name_1 = 'wgact_plugin_options_1';
12
+ $option_name_2 = 'wgact_plugin_options_2';
13
+ $option_name_3 = 'wgact_plugin_options';
14
+
15
+
16
+ delete_option( $option_name_1 );
17
+ delete_option( $option_name_2 );
18
+ delete_option( $option_name_3 );
19
+
20
+ // For site options in Multisite
21
+ delete_site_option( $option_name_1 );
22
+ delete_site_option( $option_name_2 );
23
+ delete_site_option( $option_name_3 );
wgact.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Google AdWords dynamic conversion value tracking for WooCommerce.
6
  * Author: Wolf+Bär GmbH
7
  * Author URI: https://wolfundbaer.ch
8
- * Version: 1.2.2
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-google-adwords-conversion-tracking-tag
11
  **/
@@ -39,22 +39,11 @@ class WGACT {
39
  // Load textdomain
40
  add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
41
 
42
- // insert the conversion code only for visitors of the site
43
- add_action( 'plugins_loaded', array( $this, 'run_conversion_pixel_for_visitor' ) );
44
 
45
  }
46
 
47
- // only run the conversion code for visitors, not for the admin or shop managers
48
- public function run_conversion_pixel_for_visitor() {
49
-
50
- // don't load the pixel if a shop manager oder the admin is logged in
51
- if ( ! current_user_can( 'edit_others_pages' ) ) {
52
-
53
- // add the Google AdWords tag to the thankyou part of the page within the body tags
54
- add_action( 'woocommerce_thankyou', array( $this, 'GoogleAdWordsTag' ) );
55
- }
56
- }
57
-
58
  // Load text domain function
59
  public function load_plugin_textdomain() {
60
  load_plugin_textdomain( 'woocommerce-google-adwords-conversion-tracking-tag', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
@@ -63,7 +52,7 @@ class WGACT {
63
  // adds a link on the plugins page for the wgact settings
64
  function wgact_settings_link( $links, $file ) {
65
  if ( $file == plugin_basename( __FILE__ ) ) {
66
- $links[] = '<a href="' . admin_url( "admin.php?page=do_wgact" ) . '">' . __( 'Settings' ) . '</a>';
67
  }
68
 
69
  return $links;
@@ -71,8 +60,8 @@ class WGACT {
71
 
72
  // add the admin options page
73
  function wgact_plugin_admin_add_page() {
74
- //add_options_page('WGACT Plugin Page', 'WGACT Plugin Menu', 'manage_options', 'do_wgact', array($this, 'wgact_plugin_options_page'));
75
- add_submenu_page( 'woocommerce', esc_html__( 'AdWords Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag' ), esc_html__( 'AdWords Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag' ), 'manage_options', 'do_wgact', array(
76
  $this,
77
  'wgact_plugin_options_page'
78
  ) );
@@ -84,49 +73,57 @@ class WGACT {
84
  ?>
85
 
86
  <br>
87
- <div style="background: #eee; width: 772px">
88
- <div
89
- style="background: #ccc; padding: 10px; font-weight: bold"><?php esc_html_e( 'AdWords Conversion Tracking Settings', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?></div>
90
- <form action="options.php" method="post">
91
- <?php settings_fields( 'wgact_plugin_options' ); ?>
92
- <?php do_settings_sections( 'do_wgact' ); ?>
93
- <br>
94
- <table class="form-table" style="margin: 10px">
95
- <tr>
96
- <th scope="row" style="white-space: nowrap">
97
- <input name="Submit" type="submit" value="<?php esc_attr_e( 'Save Changes' ); ?>"
98
- class="button"/>
99
- </th>
100
- </tr>
101
- </table>
102
- </form>
103
- </div>
104
- <br>
105
- <div style="background: #eee; width: 772px">
106
- <div style="background: #ccc; padding: 10px; font-weight: bold"><?php esc_html_e( 'Donation', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?></div>
107
- <table class="form-table" style="margin: 10px">
108
- <tr>
109
- <th scope="row">
110
- <div
111
- style="padding: 10px"><?php esc_html_e( 'This plugin was developed by', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
112
- <a href="http://www.wolfundbaer.ch" target="_blank">Wolf + Bär GmbH</a>
113
- <p><?php esc_html_e( 'Buy me a beer if you like the plugin.', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
114
- <br>
115
- <?php esc_html_e( 'If you want me to continue developing the plugin buy me a few more beers. Although, I probably will continue to develop the plugin anyway. It would be just much more fun if I had a few beers to celebrate my milestones.', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
116
- </div>
117
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
118
- <input type="hidden" name="cmd" value="_s-xclick">
119
- <input type="hidden" name="hosted_button_id" value="UE3D2AW8YTML8">
120
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif"
121
- name="submit" alt="PayPal - The safer, easier way to pay online!">
122
- <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1"
123
- height="1">
124
- </form>
125
- </th>
126
- </tr>
127
- </table>
128
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  <?php
131
  }
132
 
@@ -136,18 +133,18 @@ class WGACT {
136
  //register_setting( 'plugin_options', 'plugin_options', 'wgact_plugin_options_validate' );
137
  register_setting( 'wgact_plugin_options', 'wgact_plugin_options_1' );
138
  register_setting( 'wgact_plugin_options', 'wgact_plugin_options_2' );
139
- add_settings_section( 'wgact_plugin_main', esc_html__( 'Main Settings', 'woocommerce-google-adwords-conversion-tracking-tag' ), array(
140
  $this,
141
  'wgact_plugin_section_text'
142
- ), 'do_wgact' );
143
  add_settings_field( 'wgact_plugin_text_string_1', esc_html__( 'Conversion ID', 'woocommerce-google-adwords-conversion-tracking-tag' ), array(
144
  $this,
145
  'wgact_plugin_setting_string_1'
146
- ), 'do_wgact', 'wgact_plugin_main' );
147
  add_settings_field( 'wgact_plugin_text_string_2', esc_html__( 'Conversion Label', 'woocommerce-google-adwords-conversion-tracking-tag' ), array(
148
  $this,
149
  'wgact_plugin_setting_string_2'
150
- ), 'do_wgact', 'wgact_plugin_main' );
151
  }
152
 
153
  function wgact_plugin_section_text() {
@@ -188,21 +185,6 @@ class WGACT {
188
  return $newinput;
189
  }
190
 
191
- private function get_conversion_id() {
192
- $opt = get_option( 'wgact_plugin_options_1' );
193
- $conversion_id = $opt['text_string'];
194
-
195
- return $conversion_id;
196
- }
197
-
198
- private function get_conversion_label() {
199
- $opt = get_option( 'wgact_plugin_options_2' );
200
- $conversion_label = $opt['text_string'];
201
-
202
- return $conversion_label;
203
- }
204
-
205
- // insert the Google AdWords tag into the page
206
  public function GoogleAdWordsTag( $order_id ) {
207
 
208
  $conversion_id = $this->get_conversion_id();
@@ -214,24 +196,59 @@ class WGACT {
214
 
215
  $order_total = apply_filters( 'wgact_conversion_value_filter', $order_total, $order );
216
 
 
 
 
 
 
 
217
  // Only run conversion script if the payment has not failed. (has_status('completed') is too restrictive)
218
  // And use the order meta to check if the conversion code has already run for this order ID. If yes, don't run it again.
219
- if ( ! $order->has_status( 'failed' ) && ( ( get_post_meta( $order_id, '_WGACT_conversion_pixel_fired', true ) != "true" ) ) ) {
 
220
  ?>
221
 
222
- <!-- START Google Code for Sales (AdWords) Conversion Page -->
223
-
224
  <div style="display:inline;">
225
  <img height="1" width="1" style="border-style:none;" alt=""
226
- src="//www.googleadservices.com/pagead/conversion/<?php echo $conversion_id; ?>/?value=<?php echo $order_total; ?>&amp;currency_code=<?php echo $order->get_order_currency(); ?>&amp;label=<?php echo $conversion_label; ?>&amp;guid=ON&amp;script=0"/>
227
  </div>
228
 
229
- <!-- END Google Code for Sales (AdWords) Conversion Page -->
230
 
231
  <?php
232
  // Set the order ID meta after the conversion code has run once.
233
  update_post_meta( $order_id, '_WGACT_conversion_pixel_fired', 'true' );
 
 
 
 
 
 
 
 
 
 
234
  } // end if order status
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
  }
237
 
5
  * Description: Google AdWords dynamic conversion value tracking for WooCommerce.
6
  * Author: Wolf+Bär GmbH
7
  * Author URI: https://wolfundbaer.ch
8
+ * Version: 1.3.6
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-google-adwords-conversion-tracking-tag
11
  **/
39
  // Load textdomain
40
  add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
41
 
42
+ // add the Google AdWords tag to the thankyou part of the page within the body tags
43
+ add_action( 'woocommerce_thankyou', array( $this, 'GoogleAdWordsTag' ) );
44
 
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
47
  // Load text domain function
48
  public function load_plugin_textdomain() {
49
  load_plugin_textdomain( 'woocommerce-google-adwords-conversion-tracking-tag', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
52
  // adds a link on the plugins page for the wgact settings
53
  function wgact_settings_link( $links, $file ) {
54
  if ( $file == plugin_basename( __FILE__ ) ) {
55
+ $links[] = '<a href="' . admin_url( "admin.php?page=wgact" ) . '">' . __( 'Settings' ) . '</a>';
56
  }
57
 
58
  return $links;
60
 
61
  // add the admin options page
62
  function wgact_plugin_admin_add_page() {
63
+ //add_options_page('WGACT Plugin Page', 'WGACT Plugin Menu', 'manage_options', 'wgact', array($this, 'wgact_plugin_options_page'));
64
+ add_submenu_page( 'woocommerce', esc_html__( 'AdWords Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag' ), esc_html__( 'AdWords Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag' ), 'manage_options', 'wgact', array(
65
  $this,
66
  'wgact_plugin_options_page'
67
  ) );
73
  ?>
74
 
75
  <br>
76
+ <div style="float: right; padding-right: 20px">
77
+ <div style="float:left; margin-right: 10px">Please tell us how much you like the plugin!</div>
78
+ <div style="float:left"><?php require( 'includes/rating.php' ); ?></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  </div>
80
+ <div style="width:980px; float: left; margin: 5px">
81
+ <div style="float:left; margin: 5px; margin-right:20px; width:750px">
82
+ <div style="background: #0073aa; padding: 10px; font-weight: bold; color: white; border-radius: 2px">
83
+ <?php esc_html_e( 'Google AdWords Conversion Tracking Settings', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
84
+ </div>
85
+ <form action="options.php" method="post">
86
+ <?php settings_fields( 'wgact_plugin_options' ); ?>
87
+ <?php do_settings_sections( 'wgact' ); ?>
88
+ <br>
89
+ <table class="form-table" style="margin: 10px">
90
+ <tr>
91
+ <th scope="row" style="white-space: nowrap">
92
+ <input name="Submit" type="submit" value="<?php esc_attr_e( 'Save Changes' ); ?>"
93
+ class="button button-primary"/>
94
+ </th>
95
+ </tr>
96
+ </table>
97
+ </form>
98
 
99
+ <br>
100
+ <div
101
+ style="background: #0073aa; padding: 10px; font-weight: bold; color: white; margin-bottom: 20px; border-radius: 2px">
102
+ <span>
103
+ <?php esc_html_e( 'Profit Driven Marketing by Wolf+Bär', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
104
+ </span>
105
+ <span style="float: right;">
106
+ <a href="https://wolfundbaer.ch/?utm_source=WGACT&utm_medium=plugin&utm_campaign=WGACT-Plugin"
107
+ target="_blank" style="color: white">
108
+ <?php esc_html_e( 'Visit us here: https://wolfundbaer.ch', 'woocommerce-google-dynamic-retargeting-tag' ) ?>
109
+ </a>
110
+ </span>
111
+ </div>
112
+ </div>
113
+ <div style="float: left; margin: 5px">
114
+ <a href="https://wordpress.org/plugins/woocommerce-google-dynamic-retargeting-tag/" target="_blank">
115
+ <img src="<?php echo( plugins_url( 'images/wgdr-icon-256x256.png', __FILE__ ) ) ?>" width="150px"
116
+ height="150px">
117
+ </a>
118
+ </div>
119
+ <div style="float: left; margin: 5px">
120
+ <a href="https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/"
121
+ target="_blank">
122
+ <img src="<?php echo( plugins_url( 'images/wgact-icon-256x256.png', __FILE__ ) ) ?>" width="150px"
123
+ height="150px">
124
+ </a>
125
+ </div>
126
+ </div>
127
  <?php
128
  }
129
 
133
  //register_setting( 'plugin_options', 'plugin_options', 'wgact_plugin_options_validate' );
134
  register_setting( 'wgact_plugin_options', 'wgact_plugin_options_1' );
135
  register_setting( 'wgact_plugin_options', 'wgact_plugin_options_2' );
136
+ add_settings_section( 'wgact_plugin_main', esc_html__( 'Settings', 'woocommerce-google-adwords-conversion-tracking-tag' ), array(
137
  $this,
138
  'wgact_plugin_section_text'
139
+ ), 'wgact' );
140
  add_settings_field( 'wgact_plugin_text_string_1', esc_html__( 'Conversion ID', 'woocommerce-google-adwords-conversion-tracking-tag' ), array(
141
  $this,
142
  'wgact_plugin_setting_string_1'
143
+ ), 'wgact', 'wgact_plugin_main' );
144
  add_settings_field( 'wgact_plugin_text_string_2', esc_html__( 'Conversion Label', 'woocommerce-google-adwords-conversion-tracking-tag' ), array(
145
  $this,
146
  'wgact_plugin_setting_string_2'
147
+ ), 'wgact', 'wgact_plugin_main' );
148
  }
149
 
150
  function wgact_plugin_section_text() {
185
  return $newinput;
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  public function GoogleAdWordsTag( $order_id ) {
189
 
190
  $conversion_id = $this->get_conversion_id();
196
 
197
  $order_total = apply_filters( 'wgact_conversion_value_filter', $order_total, $order );
198
 
199
+ ?>
200
+
201
+
202
+ <!-- START Google Code for Sales (AdWords) Conversion Page -->
203
+ <?php
204
+
205
  // Only run conversion script if the payment has not failed. (has_status('completed') is too restrictive)
206
  // And use the order meta to check if the conversion code has already run for this order ID. If yes, don't run it again.
207
+ // Also don't run the pixel if an admin or shop manager is logged in.
208
+ if ( ! $order->has_status( 'failed' ) && ( ( get_post_meta( $order_id, '_WGACT_conversion_pixel_fired', true ) != "true" ) ) && ! current_user_can( 'edit_others_pages' ) ) {
209
  ?>
210
 
 
 
211
  <div style="display:inline;">
212
  <img height="1" width="1" style="border-style:none;" alt=""
213
+ src="//www.googleadservices.com/pagead/conversion/<?php echo $conversion_id; ?>/?value=<?php echo $order_total; ?>&amp;currency_code=<?php echo $order->get_order_currency(); ?>&amp;label=<?php echo $conversion_label; ?>&amp;guid=ON&amp;oid=<?php echo $order_id; ?>&amp;script=0"/>
214
  </div>
215
 
 
216
 
217
  <?php
218
  // Set the order ID meta after the conversion code has run once.
219
  update_post_meta( $order_id, '_WGACT_conversion_pixel_fired', 'true' );
220
+ } else {
221
+
222
+ ?>
223
+
224
+ <!-- The AdWords pixel has not been inserted. Possible reasons: -->
225
+ <!-- You are logged into WooCommerce as admin or shop manager. -->
226
+ <!-- The order payment has failed. -->
227
+ <!-- The pixel has already been fired. To prevent double counting the pixel is not being fired again. -->
228
+
229
+ <?php
230
  } // end if order status
231
+
232
+ ?>
233
+
234
+ <!-- END Google Code for Sales (AdWords) Conversion Page -->
235
+ <?php
236
+ }
237
+
238
+ private function get_conversion_id() {
239
+ $opt = get_option( 'wgact_plugin_options_1' );
240
+ $conversion_id = $opt['text_string'];
241
+
242
+ return $conversion_id;
243
+ }
244
+
245
+ // insert the Google AdWords tag into the page
246
+
247
+ private function get_conversion_label() {
248
+ $opt = get_option( 'wgact_plugin_options_2' );
249
+ $conversion_label = $opt['text_string'];
250
+
251
+ return $conversion_label;
252
  }
253
  }
254