How can we help?

Ask a question or search our knowledge base:

 

 

Integrating with Google Tag Manager

Yes!  You can use Google Tag Manager to fire the Sift Science Javascript.  Here's how:

1.  Add a new tag to your container in your GTM account:
Name this tag "Sift Science JavaScript Snippet", set the Tag Type to "Custom HTML Tag", then paste our JavaScript snippet into the HTML section: 

Note: Don't forget to add your JavaScript snippet key as the value to the '_setAccount' variable!

2.  Create Variables (previously known as Macros) for {{Sift User Id}} and {{Sift Session Id}}:

Next you need to create 2 variables (macros), one for the Sift User ID, and one for the Sift Session ID.  Set the Variable (Macro) Type for both to "Data Layer Variable".  Set the Variable (Macro) Name and Data Layer Variable Name as it appears below:

Sift Session Id:

 

Sift User Id:

 

3.  Add Firing Rule:

Next you have to add a firing rule for this tag to cause the tag to trigger.  We suggest firing the tag on all customer-facing pages, see the below image for how to configure this firing rule:

 

4.  Add the following code above your GTM container snippet:

  dataLayer = [{
'sift_user_id': 'user_id_here',
'sift_session_id': 'session_id_here'
}];
<!-- Google Tag Manager --> ... <!-- End Google Tag Manager -->

Make sure to set sift_user_id to the Users $user_id, and sift_session_id to the $session_id. You'll need to add the Data Layer code to all customer-facing pages, and can read more about the Data Layer here

5. Make sure that our snippet doesn't fire when your one of your employees logs in as a customer to investigate their account, place an order for them, etc. One option for this is to add another dataLayer variable and use it as filter to your trigger. For example, the variable could be 'isEndUser', which defaults to true and is set to false if the user is on your office IP or VPN (or if you have another way of distinguishing that one of your employees is logged in). Then, add the filter to your trigger that it will only fire when 'isEndUser' is true.

Voila! You're done! If you have any questions, feel free to ask for help.

Have more questions? Submit a request