DPO Radio

Free Website Privacy Check: Ensure Your Site's Compliant Now!

Install Guide by NextJS | AesirX Analytics

Step-by-step guide:

Step 1: Create an AesirX Account

  • Visit https://signup.aesirx.io/.
  • If you don't have an AesirX account, click on the option to create one.
  • Enter your email address, choose a privacy ID, and select "First Party Analytics" from the Solutions drop-down menu.
  • Enter your domain name and click "Verify" to submit your request.
  • Check your email (including spam folder) for a confirmation message containing your license ID.

image5.png

Step 2: Install Analytics

Install package in your NextJS App.

npm i aesirx-analytics

Step 3: Enviroment

Add the environment variable file (.env)

NEXT_PUBLIC_ENDPOINT_ANALYTICS_URL=https://example.com
NEXT_PUBLIC_SSO_CLIENT_ID=[REPLACE THIS WITH THE PROVIDED CLIENT_ID]

(https://example.com is the link to your 1st party server)
`CLIENT_ID` replace this with the provided `CLIENT_ID` from https://dapp.shield.aesirx.io/licenses

- Disable Consent Popup

add this environment variable to .env

NEXT_PUBLIC_DISABLE_ANALYTICS_CONSENT=true

Step 4:

Using with next/router:

- Added in app.js:

import { useRouter } from "next/router";
import { AnalyticsNext } from "aesirx-analytics";

<AnalyticsNext router={useRouter()}>
<[YOUR-COMPONENT]/>
</AnalyticsNext>

Track events

import { trackEvent, AnalyticsContext } from "aesirx-analytics";
const CustomEvent = () => {
 const AnalyticsStore = useContext(AnalyticsContext);
 const initTrackEvent = async () => {
  await trackEvent(endPoint, AnalyticsStore.visitor_uuid, referer, {
   event_name: "Submit",
   event_type: "submit",
   attributes: [
    {
     name: "<name-1>",
     value: "<value-1>"
    },
    {
     name: "<name-2>",
     value: "<value-2>"
    },
   ],
  });
 };
 return (
   <button on-Click={() => {initTrackEvent();}}> Search </button>
 );
}

(endPoint is the link to your 1st party server which must be installed)

(referer is the referer domain)

Enjoyed this read? Share the blog!