Skip to main content

Click Tracking

Overview

This domain has three tables: tracking_log (read/click/send events generated by every kind of content), tracking_token (short-link tokens together with their real destinations), and tracking_line_users (a mapping of tracking keys to the LINE users who followed them).

Table tracking_log

ColumnTypeNullableDefaultDescription
idUUIDNOgen_random_uuid()Primary key of the log entry
redirect_idTEXTYES-Reference id of the redirect that produced this log entry
tokenTEXTYES-Token of the followed link (matches tracking_token.token)
organization_idINTEGERNO-Owning organization (FK to organization.id)
line_oa_idINTEGERNO-LINE OA where the event occurred (FK to line_oa.id)
line_uidTEXTYES-LINE user ID of the actor (NULL when not identifiable)
service"TrackingService"NOredirectChannel that captured the event: webhook or redirect
action_type"ActionType"NOreadAction kind: read, click, send
type"TrackingType"NOassetWhat was tracked: message, uri, asset, postback
content_type"ContentType"YES-Source content type: rich_menu, campaign, auto_response, trigger_rule, lead_generation
campaign_idINTEGERYES-Source campaign (FK to campaign.id)
rich_menu_idINTEGERYES-Source rich menu (FK to rich_menu.id)
rich_menu_action_indexINTEGERYES-Index of the tapped rich menu area
rich_message_idINTEGERYES-Source message id
rich_message_indexTEXTYES-Position/part of the message that was tapped
auto_response_idINTEGERYES-Source auto-response rule
trigger_rule_idINTEGERYES-Source trigger rule
tracking_labelTEXTYES-User-defined label for grouping statistics
titleTEXTNO-Name of the tracked item at the time of the event
short_urlTEXTYES-Short link the user followed
original_urlTEXTYES-Real destination URL that was redirected to
raw_dataJSONBYES-Raw event data, e.g. the webhook payload or request headers
created_dateTIMESTAMPTZ(3)NOnow()When the event occurred
rich_menu_archive_idINTEGERYES-Source archived rich menu (FK to rich_menu_archive.id)

Table tracking_token

ColumnTypeNullableDefaultDescription
idUUIDNOgen_random_uuid()Primary key of the token
tokenTEXTNO-Token value used in the short link (unique table-wide)
content_type"ContentType"NO-Content type the token is bound to
content_idINTEGERNO-Content id the token is bound to, interpreted per content_type
action_indexINTEGERNO-Index of the action/tappable area within that content
destination_urlTEXTNO-Real destination URL to redirect to
tracking_labelTEXTYES-Label for grouping statistics
organization_idINTEGERNO-Owning organization
line_oa_idINTEGERNO-Owning LINE OA (FK to line_oa.id)
line_oa_hashTEXTNO-LINE OA hash used to compose the short URL
metadataJSONBYES-Additional token metadata
status"CommonStatus"NOactiveToken status (active, inactive, expired, ...)
created_dateTIMESTAMPTZ(3)NOnow()Token creation timestamp
created_byINTEGERNO0User who created the record
updated_dateTIMESTAMPTZ(3)YES-Last update timestamp (maintained automatically)
updated_byINTEGERYES0User who last updated the record
deleted_dateTIMESTAMPTZ(3)YES-Soft-delete timestamp
expires_atTIMESTAMPTZ(3)YES-Token expiry timestamp (NULL means never expires)

Table tracking_line_users

ColumnTypeNullableDefaultDescription
idUUIDNOgen_random_uuid()Primary key of the record
tracking_keyTEXTNO-Tracking key this user followed
line_user_idTEXTNO-LINE user ID of the person who followed it
content_type"ContentType"NO-Content type the tracking key belongs to
content_idINTEGERNO-Content id the tracking key belongs to
organization_idINTEGERNO-Owning organization
line_oa_idINTEGERNO-Related LINE OA
created_atTIMESTAMPTZ(6)NOnow()First recorded timestamp
updated_atTIMESTAMPTZ(6)NOnow()Last update timestamp (maintained automatically)

Notes

  • FKs on tracking_log: organization_id to organization.id, line_oa_id to line_oa.id, campaign_id to campaign.id, rich_menu_id to rich_menu.id, rich_menu_archive_id to rich_menu_archive.id, and the composite (line_uid, line_oa_id, organization_id) to line_user (user_id, line_oa_id, organization_id).
  • tracking_token.token carries a unique constraint; tracking_line_users has the unique constraint uk_tracking_key_line_user_id on (tracking_key, line_user_id), so a user has at most one row per tracking key.
  • tracking_log carries six composite indexes covering queries by user, by campaign, by rich menu, by channel/type, and by per-part message clicks — each led by created_date or a filtering key.
  • tracking_log has no soft-delete column because it is an append-only log.
  • tracking_line_users uses microsecond precision (TIMESTAMPTZ(6)), unlike the other two tables which use TIMESTAMPTZ(3).