Integrating with Lead Gen & CRM's shopping cart allows you to automatically record web transactions from your online store and attribute those sales to Lead Gen & CRM's leads and campaigns.
This enables you to measure your end-to-end marketing ROI for eCommerce based businesses directly in Lead Gen & CRM.
This article will detail how to integrate your shopping cart with WooCommerce.
Article Contents
Trial | ||
Essential | ✓ | |
Advanced | ✓ | |
Ultimate | ✓ |
Administrators | ✓ | |
Company Managers | ||
Marketing Managers | ||
Sales Managers | ||
Salespersons | ||
Jr. Salespersons |
Integrating Shopping Carts
In order to integrate Lead Gen & CRM with WooCommerce, you need to have administrator access to your Wordpress account.
In addition, you will need administrator access to Lead Gen & CRM.
To set up and integrate a shopping cart, do the following:
- Open a new tab in your browser.
- Log into Wordpress.
- Click Plugins > Add New in the left menu.
- Search for WooCommerce.
- Install the plugin.
- Click Editor, located under Appearance in the left menu.
- Open the functions.php file in the right menu.
- Add the code snippet located below this procedure to the bottom of your functions.php file.
- Locate
'Store Name'
in the code. - Change this to be the name of your online store.
- Save the functions.php file.
- Create a product in your store that is sold for $0.00.
- Purchase that product to test the integration.
Once purchased, that transaction should now show up in Lead Gen & CRM's shopping cart.
Important: While Shopping Cart Abandonment was created to work with various platforms, the implementation and ease of use will vary by platform. Usually, we do not support abandonment for WooCommerce without an additional plugin. Lead Gen & CRM recommends having a developer handle abandonment implementation. Pay close attention to the code that you add to functions.php. If you add incorrect code, you may be locked out of your Wordpress account.
Note: If the lead's email, first name, and last name are passed in the setTransaction
call, it will also establish tracking on the lead (and create the lead if they do not exist in Lead Gen & CRM).
Code Snippet for Functions.PHP File
The following is the supplied code snippet for use with Step 7 of the above procedure:
/* SharpSpring WooCommerce integration
* This code will push completed orders and new leads to SharpSpring, but this integration does not support abandoned carts
*/
function my_custom_tracking( $order_id ) {
//Get the order from WooCommerce
$order = wc_get_order( $order_id );
$billing = $order->get_address('billing');
?>
<script type='text/javascript'>
// SharpSpring setTransaction for WooCommerce
_ss.push(['_setTransaction', {
'transactionID': '<?php echo $order->get_order_number(); ?>',
'storeName': 'Store Name',
'total': '<?php echo $order->get_total(); ?>',
'tax': '<?php echo $order->get_total_tax(); ?>',
'shipping': '<?php echo $order->get_total_shipping(); ?>',
'city': '<?php echo $billing['city']; ?>',
'state': '<?php echo $billing['state']; ?>',
'zipcode': '<?php echo $billing['postcode']; ?>',
'country': '<?php echo $billing['country']; ?>',
'firstName' : '<?php echo $billing['first_name']; ?>', // optional parameter
'lastName' : '<?php echo $billing['last_name']; ?>', // optional parameter
'emailAddress' :'<?php echo $billing['email']; ?>' // optional parameter
}]);
<?php
//Get and loop through the items in the order
$order_item = $order->get_items();
foreach( $order_item as $product ) {
$product_sku_array = new WC_Product($product['product_id']);
$product_sku = $product_sku_array->get_sku();
?>
//SharpSpring addTransactionItem for WooCommerce
_ss.push(['_addTransactionItem', {
'transactionID':'<?php echo $order->get_order_number(); ?>',
'itemCode': '<?php echo $product_sku; ?>',
'productName': '<?php echo $product['name']; ?>',
'category': 'General',
'price': '<?php echo $product['line_total']; ?>',
'quantity': '<?php echo $product['qty']; ?>'
}]);
<?php
}
?>
//SharpSpring completeTransaction after all items have been added to the transaction
_ss.push(['_completeTransaction', {
'transactionID': '<?php echo $order->get_order_number(); ?>'
}]);
</script>
<?php
}
add_action( 'woocommerce_thankyou', 'my_custom_tracking' );
/* End SharpSpring WooCommerce integration */