WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Piwik integration
[resolved] How Do I Make It Track My e-Commerce Purchases (3 posts)

  1. visualxl
    Member
    Posted 5 months ago #

    I have already installed WP-piwik, and this plugin.

    After the payment has been made, when I inspect the elements on the "order received" page,

    I can see this,

    jQuery(function($) {
    		try {
    			// Add order items
    
    				piwikTracker.addEcommerceItem(
    					"hw02e",			// (required) SKU: Product unique identifier
    					"HW-02E",					// (optional) Product name
    					"",	// (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
    					100,	// (recommended) Product price
    					1 						// (optional, default to 1) Product quantity
    				);
    
    			// Track order
    			piwikTracker.trackEcommerceOrder(
    				"#637",	// (required) Unique Order ID
    				110,			// (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
    				false,													// (optional) Order sub total (excludes shipping)
    				0,		// (optional) Tax amount
    				10,		// (optional) Shipping amount
    				false 													// (optional) Discount offered (set to false for unspecified parameter)
    			);
    		} catch( err ) {}
    
    });

    Purchases was not tracked under piwik. But if I were to call my own javascript, with hardcoded values below, piwik do track it.

    function addEcommerceItem() {
    // add the first product to the order
    			_paq.push(['addEcommerceItem',
    			"sku01", // (required) SKU: Product unique identifier
    			"sku01Name", // (optional) Product name
    			"productCategory", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
    			60, // (recommended) Product price
    			1 // (optional, default to 1) Product quantity
    			]);
    };
    
    function trackEcommerceOrder() {
    			_paq.push(['trackEcommerceOrder',
    			"A10000127", // (required) Unique Order ID
    			35, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
    			30, // (optional) Order sub total (excludes shipping)
    			5.5, // (optional) Tax amount
    			4.5, // (optional) Shipping amount
    			false // (optional) Discount offered (set to false for unspecified parameter)
    			]);
    };

    Kindly advice.

    https://wordpress.org/plugins/woocommerce-piwik-integration/

  2. visualxl
    Member
    Posted 5 months ago #

    Modified 'piwik-woocommerce-integration' plugin -> 'class-wc-piwik-tracker.php'

    1. Replaced piwikTracker.addEcommerceItem() and its implementation with:

    //add order
    _paq.push(['addEcommerceItem',
    "<?php echo esc_js( $_product->get_sku() ); ?>",
    "<?php echo esc_js( $item['name'] ); ?>",
    "<?php
    if ( isset( $_product->variation_data ) )
    echo esc_js( woocommerce_get_formatted_variation( $_product->variation_data, true ) );
    ?>",
    <?php echo esc_js( $order->get_item_total( $item ) ); ?>,
    <?php echo esc_js( $item['qty'] ); ?>]);

    2. Replaced piwikTracker.trackEcommerceOrder() and its implementation with:

    // Track order
    _paq.push(['trackEcommerceOrder',
    "<?php echo esc_js( $order->get_order_number() ); ?>",
    <?php echo esc_js( $order->get_total() ); ?>,
    false,
    <?php echo esc_js( $order->get_total_tax() ); ?>,
    <?php echo esc_js( $order->get_shipping() ); ?>,
    false
    ]);
    _paq.push(['trackPageView']);

    3. You may want to modify/update the plugin, and/or advise me if there is something else I need to do.

  3. ashishinfin
    Member
    Posted 1 month ago #

    I'hv done same but still its not tracking...
    I'm using wordpress 3.9.1 version and also download latest versions of "wp-piwik" and "WooCommerce Piwik integration"...

    now what can I do to track e-commerce in wordpress???
    Please help me, its urgent...

    thanks

Reply

You must log in to post.

About this Plugin

About this Topic