mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
Set unique user id for google analytics and facebook pixel. Also logged web visitor access on each page view.
Removed unique id generation from php and using internal unique id.
This commit is contained in:
parent
e68fa704d2
commit
258762da47
3 changed files with 17 additions and 4 deletions
|
@ -11,13 +11,15 @@ class Session
|
|||
|
||||
const NAMESPACE_DEFAULT = 'default',
|
||||
NAMESPACE_FLASH = 'flash',
|
||||
NAMESPACE_FLASH_REMOVE = 'flash_remove';
|
||||
NAMESPACE_FLASH_REMOVE = 'flash_remove',
|
||||
USER_ID = 'user_id';
|
||||
|
||||
public static function init()
|
||||
{
|
||||
ini_set('session.cookie_secure', IS_PRODUCTION); // send cookie over ssl only
|
||||
ini_set('session.cookie_httponly', true); // no js access to cookies
|
||||
session_start();
|
||||
ini_set('session.cookie_httponly', true); // no js access to cookies
|
||||
session_start();
|
||||
|
||||
|
||||
if (!static::get('secure_and_httponly_set')) {
|
||||
session_regenerate_id(); // ensure that old cookies get new settings
|
||||
|
@ -31,6 +33,9 @@ class Session
|
|||
static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession);
|
||||
}
|
||||
|
||||
$response = LBRY::logWebVisitor('lbry.io', $_SESSION[static::USER_ID], $_SERVER['REMOTE_ADDR']);
|
||||
$_SESSION[static::USER_ID] = $response['data']['visitor_id'];
|
||||
|
||||
static::initFlashes();
|
||||
}
|
||||
|
||||
|
|
5
lib/thirdparty/LBRY.class.php
vendored
5
lib/thirdparty/LBRY.class.php
vendored
|
@ -75,4 +75,9 @@ class LBRY
|
|||
return Curl::post(static::getApiUrl("/yt/update"), ['status_token' => $status_token, 'new_email' => $email, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent], ['json_response' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function logWebVisitor($site, $visitorID, $IPAddress)
|
||||
{
|
||||
return Curl::post(static::getApiUrl("/visitor/new"), ['site' => $site, 'visitor_id' => $visitorID, 'ip_address' => $IPAddress], ['json_response' => true]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,16 @@
|
|||
|
||||
ga('create', 'UA-60403362-1', 'auto');
|
||||
ga('require', 'GTM-NT8579P');
|
||||
ga('set', 'userId', '<?php echo $_SESSION[Session::USER_ID] ?>');
|
||||
ga('send', 'pageview');
|
||||
|
||||
!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window,document,'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
||||
|
||||
fbq('init', '1618717031725766');
|
||||
fbq('init', '1618717031725766',{uid: '<?php echo $_SESSION[Session::USER_ID] ?>'}));
|
||||
fbq('track', '<?php echo Response::getFacebookPixelAnalyticsType() ?>');
|
||||
|
||||
<?php LBRY::logWebVisitor('lbry.io', $_SESSION[Session::USER_ID], $_SERVER['REMOTE_ADDR'])?>
|
||||
|
||||
</script>
|
||||
<?php else: ?>
|
||||
<script>
|
||||
|
|
Loading…
Add table
Reference in a new issue