-
Notifications
You must be signed in to change notification settings - Fork 1
/
tracking.php
33 lines (26 loc) · 1006 Bytes
/
tracking.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
//##copyright##
if (iaView::REQUEST_HTML == $iaView->getRequestType())
{
// affiliate member id
$memberId = isset($iaCore->requestPath[0]) ? (int)$iaCore->requestPath[0] : 0;
// affiliate product id used for tracking
$productId = isset($iaCore->requestPath[1]) ? (int)$iaCore->requestPath[1] : 0;
// check referer
$visitorReferrer = getenv('HTTP_REFERER');
if ($memberId)
{
$iaVisitor = $iaCore->factoryPackage('visitor', IA_CURRENT_PACKAGE);
// get unique tracking ID for a visitor in case it's not set
$trackingSalt = isset($_COOKIE['IA_AFF_TRACKING']) ? $_COOKIE['IA_AFF_TRACKING'] : $memberId . iaUtil::generateToken(20);
// update tracking record
$iaVisitor->updateTrackingRecords($trackingSalt, $memberId, $productId, $visitorReferrer);
}
// redirect to the page
$redirectUrl = $iaCore->get('aff_incoming_page', IA_URL);
if ($productId)
{
$redirectUrl = $iaDb->one('`url`', iaDb::convertIds($productId), 'affiliates_products');
}
iaUtil::go_to($redirectUrl);
}