Register your account at https://dapp.shield.aesirx.io/. You will then get an email for user creation account.
Activate your account by clicking verify in the email
Login to https://dapp.shield.aesirx.io/licenses site to get your LICENSE in your profile.
Download analytics.js from https://github.com/aesirxio/analytics/releases/latest.
Copy file analytics.js to your project
Add script to head
<script>
window.aesirx1stparty = "https://example.com"
window.aesirxClientID="[REPLACE THIS WITH THE PROVIDED CLIENT_ID]"
</script>
<script async defer src="YOUR_PROJECT_PATH/analytics.js"></script>
(https://example.com is the link to your 1st party server)
(CLIENT_IDreplace this with the provided CLIENT_ID from https://dapp.shield.aesirx.io/licenses
(CLIENT_SECRET replace this with the provided CLIENT_SECRET from https://dapp.shield.aesirx.io/licenses
- Disable Consent Popup
<script>
window.disableAnalyticsConsent = "true"
</script>
To track events, simply add special data-attribute to the element you want to track. For example, you might have a button with the following code:
<button class="button"
data-aesirx-event-name="sign up"
data-aesirx-event-type="login"
data-aesirx-event-attribute-a="value-a"
data-aesirx-event-attribute-b="value-b"
>
Sign Up
</button>
Add data-attribute with the following format:
data-aesirx-event-name="<event-name>"
data-aesirx-event-type="<event-type>"
data-aesirx-event-attribute-<attribute-name-1>="<attribute-value-1>"
data-aesirx-event-attribute-<attribute-name-2>="<attribute-value-2>"
window.trackEvent(endpoint, event_uuid, visitor_uuid, referrer, data)
(endpoint is the link to your 1st party server which must be installed)
(event_uuid is the params get from url - it will auto generated)
(visitor_uuid is the params get from url - it will auto generated)
(referrer is the referrer domain)
(data is the data you want to track)
For example:
trackEvent(
"https://example.com",
visitor_uuid,
"https://aesirx.io",
{
event_name: "<event_name>",
event_type: "<event_type>",
attributes: [
{
name: "<name-1>",
value: "<value-1>"
},
{
name: "<name-2>",
value: "<value-2>"
},
],
}
);
Enjoyed this read? Share the blog!