Changeset 3404142
- Timestamp:
- 11/27/2025 01:33:02 PM (4 months ago)
- Location:
- trackboxx-analytics/trunk
- Files:
-
- 4 edited
-
includes/class-trackboxx.php (modified) (1 diff)
-
public/class-trackboxx-public.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
trackboxx.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trackboxx-analytics/trunk/includes/class-trackboxx.php
r3358630 r3404142 184 184 $this->loader->add_action( 'wp_print_scripts', $plugin_public, 'enqueue_scripts_old' ); 185 185 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 186 187 // WooCommerce tracking hooks 186 188 $this->loader->add_action( 'woocommerce_before_thankyou', $plugin_public, 'wc_purchase_tracking_script' ); 187 189 $this->loader->add_action( 'woocommerce_add_to_cart', $plugin_public, 'wc_add_to_cart', 10, 2 ); 190 191 // New View Cart tracking hooks (added in version 1.3.34) 192 $this->loader->add_action( 'wp_footer', $plugin_public, 'wc_view_cart_tracking' ); 193 $this->loader->add_action( 'wp_footer', $plugin_public, 'wc_view_product_tracking' ); 188 194 } 189 195 -
trackboxx-analytics/trunk/public/class-trackboxx-public.php
r3358630 r3404142 183 183 } 184 184 185 /** 186 * Track WooCommerce View Cart action. 187 * 188 * @since 1.3.34 189 * @return void 190 */ 191 public function wc_view_cart_tracking() { 192 if ( !function_exists( 'is_cart' ) || !is_cart() ) { 193 return; 194 } 195 196 $cart = WC()->cart; 197 if ( ! $cart || $cart->is_empty() ) { 198 return; 199 } 200 201 $options = get_option( 'trackboxx_tracking_id' ); 202 $trackboxx_id = isset( $options['input'] ) ? sanitize_text_field( $options['input'] ) : ''; 203 204 if ( empty( $trackboxx_id ) ) { 205 return; 206 } 207 208 // Build tracking data 209 $tracking_data = array( 210 array( 'type' => 'ViewCart' ), 211 array( 212 'type' => 'cart', 213 'amount' => floatval( $cart->get_cart_contents_total() ) 214 ), 215 ); 216 217 // Add all products in cart 218 foreach ( $cart->get_cart() as $cart_item ) { 219 $product = $cart_item['data']; 220 if ( $product ) { 221 $tracking_data[] = array( 222 'type' => 'product', 223 'name' => wp_strip_all_tags( $product->get_name() ), 224 'price' => floatval( $product->get_price() ) * intval( $cart_item['quantity'] ), 225 ); 226 } 227 } 228 229 $params_json = wp_json_encode( $tracking_data ); 230 $inline_js = "trackboxx('Purchase', " . $params_json . ");"; 231 $this->enqueue_public_scripts( $inline_js ); 232 } 233 234 /** 235 * Track WooCommerce View Product action. 236 * 237 * @since 1.3.34 238 * @return void 239 */ 240 public function wc_view_product_tracking() { 241 if ( !function_exists( 'is_product' ) || !is_product() ) { 242 return; 243 } 244 245 $options = get_option( 'trackboxx_tracking_id' ); 246 $trackboxx_id = isset( $options['input'] ) ? sanitize_text_field( $options['input'] ) : ''; 247 248 if ( empty( $trackboxx_id ) ) { 249 return; 250 } 251 252 global $product; 253 254 if ( $product instanceof WC_Product ) { 255 $tracking_data = array( 256 array( 'type' => 'ViewProduct' ), 257 array( 258 'type' => 'product', 259 'name' => $product->get_name(), 260 'price' => $product->get_price() 261 ) 262 ); 263 264 $params_json = wp_json_encode( $tracking_data ); 265 $inline_js = "trackboxx('Purchase', " . $params_json . ");"; 266 $this->enqueue_public_scripts( $inline_js ); 267 } 268 } 269 185 270 /** 186 271 * Track WooCommerce Purchase action. … … 290 375 ?> 291 376 <!-- Trackboxx Analytics --> 292 <script>377 <script> 293 378 (function(d, s, id, w, f){ 294 w[f] = w[f] || function() { (w[f].q = w[f].q || []).push(arguments) }; 379 w[f] = w[f] || function() { (w[f].q = w[f].q || []).push(arguments) 380 }; 295 381 var js, fjs = d.getElementsByTagName(s)[0]; 296 382 if (d.getElementById(id)) { return; } … … 302 388 }(document, 'script', 'trackboxx-script', window, 'trackboxx')); 303 389 trackboxx('set', 'siteId', <?php echo wp_json_encode( $id ); ?>); 304 trackboxx('trackPageview'); 305 </script> 390 trackboxx('trackPageview'); 391 </script> 392 306 393 <?php 307 394 } -
trackboxx-analytics/trunk/readme.txt
r3361053 r3404142 115 115 == Changelog == 116 116 117 118 = 1.3.34 = 119 * Added view cart tracking functionality for improved event accuracy. 120 * Added product view tracking to support enhanced behavioral analytics. 121 * Extended WooCommerce integration to enable precise cart view detection. 122 * Enables Trackboxx to calculate cart abandonment rates more reliably. 123 * Updated public classes and loader to include new tracking hooks. 124 117 125 = 1.3.33 = 118 126 * Added new signup information block to the onboarding wizard. -
trackboxx-analytics/trunk/trackboxx.php
r3361053 r3404142 5 5 * Author: Trackboxx 6 6 * Author URI: https://trackboxx.com/ 7 * Version: 1.3.3 37 * Version: 1.3.34 8 8 * Requires PHP: 8.0 9 9 * Text Domain: trackboxx-analytics … … 23 23 * Currently plugin version. 24 24 */ 25 define( 'TRACKBOXX_VERSION', '1.3.3 3' );25 define( 'TRACKBOXX_VERSION', '1.3.34' ); 26 26 27 27
Note: See TracChangeset
for help on using the changeset viewer.