diff --git a/init.php b/init.php
index f302dbc..970dd13 100644
--- a/init.php
+++ b/init.php
@@ -35,19 +35,23 @@
function ganalytics_add_code()
{
+ $webPropertyId = trim(OW::getConfig()->getValue('ganalytics', 'web_property_id'));
+ $userId = OW::getUser()->getId();
+ $sUid = '';
+ if ($userId > 0)
+ $sUid = '\'user_id\':\''. $userId .'\',';
+
+ $code = '
+
+
- ';
+ gtag(\'config\', \''. $webPropertyId . '\', {' . $sUid. '});
+ ';
- OW::getDocument()->appendBody($code);
+ OW::getDocument()->addCustomHeadInfo($code);
}
OW::getEventManager()->bind(OW_EventManager::ON_FINALIZE, 'ganalytics_add_code');
}