Skip to content

Visit ​

Tracks each click of an affiliate referral link.

Table: fa_visits
Class: FluentAffiliate\\App\\Models\\Visit.php

Columns ​

ColumnTypeNullableDefaultDescription
idBIGINT(20)NO—Primary key, auto-increment.
affiliate_idBIGINT(20)YES—Affiliate who earned this referral.
user_idBIGINT(20)YES—WordPress user ID of the affiliate.
referral_idBIGINT(20)YES—Referral created from this visit (if any).
urlMEDIUMTEXTYES—Destination URL linked from the creative.
referrerMEDIUMTEXTYES—HTTP referer of the visit.
utm_campaignVARCHAR(100)YES—UTM campaign parameter from the tracking URL.
utm_mediumVARCHAR(100)YES—UTM medium parameter.
utm_sourceVARCHAR(100)YES—UTM source parameter.
ipVARCHAR(100)YES—Hashed or raw visitor IP address.
created_atTIMESTAMPYES—Timestamp when the record was created.
updated_atTIMESTAMPYES—Timestamp when the record was last updated.

Relationships ​

MethodTypeTargetDescription
affiliate()belongsToAffiliateAffiliate whose link was clicked.
referral()hasOneReferralReferral created from this visit (if any).

Query Scopes ​

ScopeDescription
filterByAffiliate($id)Restrict to a specific affiliate.
filterByCampaign($campaign)Filter by UTM campaign.

Usage Example ​

php
use FluentAffiliate\App\Models\Visit;

$visits = Visit::filterByAffiliate($affiliateId)
    ->whereBetween('created_at', [$startDate, $endDate])
    ->count();

FluentAffiliate developer documentation