{"section":"tutorials","requestedLocale":"en","requestedSlug":"setting-up-device-fingerprint-for-niubiz","locale":"en","slug":"setting-up-device-fingerprint-for-niubiz","path":"docs/en/tutorials/payments/payment-settings/setting-up-device-fingerprint-for-niubiz.md","branch":"main","content":"__Device Fingerprint__ is an identifier that acts in payment processing to improve fraud risk analysis. \n\nBy collecting non-sensitive data, Device Fingerprint identifies and analyzes the security level of the device used to perform a given transaction. It also analyzes transactions previously performed with that device.\n\n> ℹ️ Each store must have only one Device Fingerprint registered. Check if you have already registered the Device Fingerprint in another connector, before proceeding with the steps below.\n\nThis article will explain how to associate the Device Fingerprint feature with the Niubiz affiliation.  \n\nThis requires generating an identifier using [Google Tag Manager](https://marketingplatform.google.com/about/tag-manager/) and then associating it to the affiliation via the Admin.   \n\n## Creating the identifier\n\n> ℹ️ This step may be outdated as it is performed in an external environment.          \n\nFirst, you need to create the identifier.\n\nFollow these instructions:\n\n1. Log in to your __Google Tag Manager__ account.\n2. From the left-nav menu, select the__ Tags tab and click on new__. \n3. Then click on __Tag configuration__. \n4. From the right-nav tag type menu, select the __\"Custom HTML\" option__. \n5. Fill in the HTML field with the following __javascript code__.\n    ```    \n    <script>\n    window.vtex.deviceFingerprint = getuuid() ;\n    console.log('fingerprint: '+window.vtex.deviceFingerprint);\n    initDFP(window.vtex.deviceFingerprint);\n    var localSessionId = null;\n    function doProfile(orgId, sessionId, hostname){\n    console.log('Starting profile using ' + hostname + ' for orgId ' + orgId + ' with sessionId ' + sessionId + ' on ' + Math.floor(Date.now() / 1000));\n    var head = document.getElementsByTagName(\"head\").item(0);\n    var url = \"https://\" + hostname + \"/tags.js?org_id=\" + orgId + \"&session_id=\" + sessionId + \"&page_id=1&allow_reprofile=1\";\n    console.log(url);\n    var script = document.createElement(\"script\");\n    script.setAttribute(\"type\", \"text/javascript\");\n    script.setAttribute(\"src\", url);\n    head.appendChild(script); console.log('Profile should have started...');\n    body = document.getElementsByTagName(\"body\").item(0);\n    noscript = document.createElement(\"noscript\");\n    iframe = document.createElement(\"iframe\");\n    iframe.setAttribute(\"style\", \"width: 100px; height: 100px; border: 0; position:absolute; top: -5000px;\");\n    iframe.setAttribute(\"src\", url);\n    noscript.appendChild(iframe);\n    body.insertBefore(noscript, body.childNodes[0]);\n    }\n    function initDFP(sessionId) {\n    localSessionId = sessionId;\n    console.log('Init profiling ', Math.floor(Date.now() / 1000))\n    var timeout = 3000;\n    var sasOrgId = \"507f9ifk\";\n    var csOrgId = \"1snn5n9w\";\n    var merchantId = \"vndp\";\n    var hostname = \"h.online-metrix.net/fp\"; \n    doProfile(sasOrgId, sessionId, \"m.vnforapps.com\");\n    setTimeout(startOnTimer(sessionId) , timeout); }\n    function startOnTimer(sessionId) {\n    var csOrgId = \"1snn5n9w\";\n    var merchantId = \"vndp\";\n    var hostname = \"h.online-metrix.net/fp\";\n    doProfile(csOrgId, merchantId + sessionId, hostname); }\n    function getuuid() {\n    var dt=new Date().getTime();\n    var uuid='xxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g,function(c){\n          var r = (dt + Math.random()*16)%16 | 0;\n      dt = Math.floor(dt/16);\n      return (c=='x' ? r : (r&0x3|0x8)).toString(16);\n      });\n    return uuid;\n    }\n    function tmx_profiling_complete(sessionId) {\n      console.log('Finished ', sessionId, '-', Math.floor(Date.now() / 1000));\n    }\n    </script>\n    ```\n6. In the __\"Advanced settings\" section__, leave the __values empty__. \n7. Click on __Triggers__.\n8. Choose the __\"Custom event\" option__.\n9. Fill in the __\"Event name\" field with the value \".*\"__\n10. Check the __\"Use regex matching\" box__.\n11. Under \"This trigger fires on\", click on the __\"Some custom events\" option__.\n12. __Save__ and publish the settings.\n\nGoogle Tag Manager will then create the identifier. \n\n> ⚠️ Please write down the ID in a place you can easily find it.\n\n##  Configuration in the VTEX Admin\n\nWith the ID in hand, you must link it with the Niubiz affiliation in the Admin.\n\nFollow the step by step instructions below:\n\n1. In the VTEX Admin, go to **Store Settings > Storefront > Checkout**, or type **Checkout** in the search bar at the top of the page.\n3. In the \"Default\" configuration box, click on __the blue gear button__.\n4. On top of the page, select the __\"Checkout\" tab__.\n5. Fill in the \"Google Tag Manager\" field with the __newly generated ID__.\n6. __Save__ your changes."}