Skip to main content

Analytics.click

Records a tap or click on any interactive UI element — buttons, links, cards, and so on. Use it to track which components users interact with and on which pages.

Signature

click is a member of the Analytics namespace object. It is not imported as a standalone function.

import { Analytics } from '@apps-in-toss/web-framework';

type Primitive = string | number | boolean | null;

type LoggerParams = {
log_name?: string;
} & {
[key: string]: Primitive;
};

declare const Analytics: {
click: (params?: LoggerParams) => Promise<void> | undefined;
};

Parameters

NameTypeRequiredDescription
paramsLoggerParamsKey-value pairs to log. Use log_name to identify the event; add any extra keys as event properties. Optional.
params.log_namestringEvent identifier used to distinguish events in the analytics dashboard.
params[key]string | number | boolean | nullAdditional context fields. Only Primitive values are allowed.

Returns

  • Promise<void> | undefined — resolves after the event is logged. The return value can be undefined depending on the environment — do not rely on it.

Permission

No permission required — Analytics.click is not bound to any PermissionName. For how permissions work in other namespaces see Guides — Permissions pattern.

Examples

Minimal

import { Analytics } from '@apps-in-toss/web-framework';

async function handleButtonClick() {
await Analytics.click({ log_name: 'cta_button_click', page: 'home' });
}

Realistic — record component and page together

import { Analytics } from '@apps-in-toss/web-framework';

function ProductCard({ productId, page }: { productId: string; page: string }) {
const handleClick = async () => {
await Analytics.click({
log_name: 'product_card_click',
component: 'product_card',
page,
product_id: productId,
});

// Navigate or trigger the actual action after logging.
};

return (
<button type="button" onClick={handleClick}>
View product
</button>
);
}

Try it live

Run the Analytics.click card on the Analytics page in sdk-example.

Open in sdk-example

External references