← All platforms

    Installation Guide · Expo (Expo Router)

    How to Add Agent Analytics to Your Website

    One script captures what visitors browse. That becomes memory your analytics can understand. And agents like Jack turn it into actions — recovery emails, demand segments, conversion insights.

    Install on Expo (Expo Router)

    🧪

    Expo (Expo Router)

    Use the @tradly/analytics SDK with Expo and Expo Router. It works in Expo Go and development builds — no native code, no config plugin.

    Medium·3 min·3 methods

    Install the SDK

    Add the @tradly/analytics package to your Expo project.

    1
    Install the package

    Works with Expo Go and development builds since there is no native module.

    Paste this
    npm install @tradly/analytics

    Create the analytics client

    Set up the client once in a shared module so every screen can use it.

    1
    Create your analytics client with the platform set to ios or android

    This powers the same createAnalytics API used by React Native.

    Paste this
    import { createAnalytics } from "@tradly/analytics";
    
    export const analytics = createAnalytics({
      projectKey: "your-tenant-id",
      app: {
        name: "My App",
        version: "1.0.0",
        platform: "android",
      },
    });
    2
    Track events and identify users

    Track supports all existing commerce and goal events; identify links anonymous history to a known user after login.

    Paste this
    await analytics.track("checkout_started", { value: "249.00" });
    await analytics.identify("tenant:123:user:456");

    Screen tracking with Expo Router

    Place a ScreenTracking component once inside the root layout so every route change is tracked.

    1
    Add a ScreenTracking component to your root layout

    Use usePathname and call analytics.screen whenever the path changes.

    Paste this
    import { Slot, usePathname } from "expo-router";
    import { useEffect } from "react";
    import { createAnalytics } from "@tradly/analytics";
    
    const analytics = createAnalytics({ projectKey: "your-tenant-id" });
    
    function ScreenTracking() {
      const pathname = usePathname();
      useEffect(() => {
        if (pathname) void analytics.screen(pathname);
      }, [pathname]);
      return null;
    }
    
    export default function RootLayout() {
      return (
        <>
          <ScreenTracking />
          <Slot />
        </>
      );
    }

    Need help? Contact support@tradly.dev or check our FAQ.

    Last updated: January 2025