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)NOPrimary key, auto-increment.
affiliate_idBIGINT(20)YESAffiliate who earned this referral.
user_idBIGINT(20)YESWordPress user ID of the affiliate.
referral_idBIGINT(20)YESReferral created from this visit (if any).
urlMEDIUMTEXTYESDestination URL linked from the creative.
referrerMEDIUMTEXTYESHTTP referer of the visit.
utm_campaignVARCHAR(100)YESUTM campaign parameter from the tracking URL.
utm_mediumVARCHAR(100)YESUTM medium parameter.
utm_sourceVARCHAR(100)YESUTM source parameter.
ipVARCHAR(100)YESHashed or raw visitor IP address.
created_atTIMESTAMPYESTimestamp when the record was created.
updated_atTIMESTAMPYESTimestamp 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();

Released under the GPL-2.0 License.