Google Analytics Integration

Using functionale of Google Analytics you have a possibility to export FraudHunt data directly into it. This option is most useful for businesses trying to optimize their conversion funnel and to those interested in full analytics on every visitor, traffic source, campaign, etc.

There are two integration options currently available: Basic (FingerprintKey) and Complex (FigerprintKEy+Score).

Both are to be integrated as a last element of your head section.

Basic Google Analytics integration

It allows to transfer the Fingerprint Key FraudHunt generates to your GA. This can later be used to detect same devices posing as different ones and to link FraudHunt Custom Reports with your GA reports.

Basic integration code:

< script>
var fhcnt = 0;

function handleFpKey(fpk) {
ga('send', 'pageview', {
  'dimension1':  fpk.toUpperCase() }); 
}
 
function send() {
    fhcnt++;
    var fpk = window.fppixel && fppixel.fpk;
    if (fpk) {
      handleFpKey(fpk);
    } else {
      __fpiGlobalVariables = {
        __fpiCb: handleFpKey
      }
      if (fhcnt <= 10) {
        setTimeout(send, 500);
      }
    }
    return fpk;
  }
 send();
</script>

The script grabs the Fingerprint Key and sends it into your GA as dimension1.

Complex Google Analytics integration

It allows to transfer the Fingerprint Key FraudHunt generates and the User Fraud Score to your GA. In addition to the reporting features Basic integration provides, the Complex integration allows on the fly evaluation of every visitor of your website.

Complex integration code:

< script>
var fhcnt = 0;
var apiHost = '//api.fraudhunt.net/';
function handleFpKey(fpKey) {
   ga('send', 'event', 'FP', 'GetFPKey', {'dimension1':  fpKey.toUpperCase() });
            urlArgs = '?fpkey=' + fpKey;
   var xhr = new XMLHttpRequest();
            xhr.open("GET", apiHost + 'GET/' + fpKey.toUpperCase() + '?type=json&token=yourcid', true);
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4) {
                    status = xhr.status;
                    if (xhr.status < 400 && xhr.responseText) {
                        var actual_JSON =JSON.parse(xhr.responseText);
      var score = actual_JSON?actual_JSON.fraudScore:0;
      ga('send', 'event', 'FP', 'GetFPScore', { 'metric1' : score });
     }
    }
            };
            xhr.send();
  }
 
function send() {
    fhcnt++;
    var fpk = window.fppixel && fppixel.fpk;
    if (fpk) {
      handleFpKey(fpk);
    } else {
      __fpiGlobalVariables = {
        __fpiCb: handleFpKey
      }
      if (fhcnt <= 10) {
        setTimeout(send, 500);
      }
    }
    return fpk;
  }
 send();
</script>
The script grabs the Fingerprint Key and sends it into your GA as dimension1 at the same time sending a request to FraudHunt API. The API then returns the User Score which is transferred to your GA as metric1.

Please note that the token for the API request is your cid and is generated during account registration.

Google Analytics setup

In order to process custom parameters and metrics in your Google Analytics, please check out Google Analytics Guidelines or follow a step-by-step guide below.

Basic Integration

Adding the FPkey parameter:

Adding the FraudScore parameter:

To create custom reports with calculated metrics, please check out these guidelines from Google.

When working with FraudHunt custom reports you need to divide the total Score Metric by the number of page views like shown below.