Integrating Sift science With WooCommerce

Naveed Ahmad
3 min readApr 7, 2016

Wondering what is Sift science ? have a look at there website

Wordering what is WooCommerce ? have a look at this page

Using Sift science with WooCommerce can significantly reduce charge backs but unfortunately at the time of writing this article Sift science don’t have any plugin for WooCommerce. This read will help you integrate Sift science with WooCommerce.

Before we start

Make sure you have installed WordPress and WooCommerce for WordPress. Also registered for an account with Sift science.

You will also need to install Code Snippets plugin for WordPress. You can get the plugin from here

Code Snippets is an easy, clean and simple way to add code snippets to your site. It removes the need to add custom snippets to your theme theme’s functions.php file.

Little bit of theory

Sift science has a very nice integration guide here do not proceed if you still haven’t read this integration guide. Take a break here go to this URL and read it once you are familiar with the integration process come back and continue this read.

Completely optional if you to read about WordPress’s functions.php file

Lets dive into it.

Sift science charge back integration has 4 parts User Activity, Checkout, Decision and Feedback. This page has more information

we will start with Tracking User Activity.

Installing JavaScript snippet to track user activity.

you can get the snippet from this page or you can copy it from here notice I have made some changes in the first two lines of this snippet.

save this snippet in a JavaScript file and name it siftsciencesnippet.js and upload it via ftp to the root of your WordPress site and make sure it is accessible through

Now login to Sift science and get your javascript snippet key you can find your key under Developer>Api Keys and then look for it in Javascript Snippet Key section.

(1) Find your Javascript snippet key

now insert this snippet key in your java-script snippet

Creating a WordPress Code Snippet and populating _user_id and _session_id

After uploading JavaScript Snippet to your WordPress root folder we need to create a WordPress Snippet which will load and Send _user_id and _session_id to JavaScript Snippet to do this lets Login to WordPress back end and look for snippets in the left menu options. If you can’t find it make sure you have installed the Code Snippet Plugin Correctly.

click “Add New” in Snippets Menu and enter the name of your snippet, the WordPress Code snippet and make sure to select radio option “Only run on site front-end”

you can copy the WordPress snippet from the following gist

do not forget to save and activate your WordPress snippet.

If you are having hard time understanding this WordPress snippet leave a Comment I will try to explain it.

At this point if you have followed everything correctly your WooCommerce site should have started sending page views to Sift science.

Next we will send Logout, Login and Create Account Activity to Sift science.