Script Tag
If you have already installed the SDK via NPM, you can skip this step.
This method allows the 0xArc SDK to be added to your project via a HTML script tag, loaded in from a CDN.
Please note that the script tag method only supports Metamask.
1. Add the script tag to your index.html
<script>
const script = document.createElement('script')
const apiKey = 'YOUR_API_KEY'
const config = {} // Add any configuration parameters you'd like here
script.src = '<https://unpkg.com/@0xarc-io/analytics>'
script.onload = function () {
ArcxAnalyticsSdk.init(apiKey, config, 'script-tag').then(function (sdk) {
window.arcx = sdk
})
}
document.head.appendChild(script)
</script>
2. Configure the API key
If you haven't already, you can retrieve your API key by following the instructions in the Retrieve your API Key docs.
Once you have your API key, set the value of the apiKey
variable to your API key.
Note that the apiKey
is required. The key is a string that uniquely identifies your project. Since it is a public key, you can safely expose it to the client.
That’s it! The 0xArc SDK will automatically detect wallet connections, referrer data, button clicks, page tracks and transactions that occur on your front-end.
You will now have access to the 0xArc SDK instance via window.arcx
anywhere in the app, in case you want to use any specific functionality described in the Tracking Events section.