I have a php shorturl website like bitly and i want to track users accessing the short urls. Is there anyway i can get the google analytics code in here and working someone? just adding it wont work, the code will not run at all. I tried to add above the code to make it work. The site is running php 7.3
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
</head>
<?php
require_once('master.php');
if ($shortUrlObj->status != "active")
{
$errorMsg = t("longer_active");
redirect(ROOT . "/404." . EXTENSION . "?e=" . urlencode($errorMsg));
}
$redirectType = SITE_CONFIG_REDIRECT_TYPE;
switch ($redirectType)
{
default:
header('HTTP/1.1 302 Moved Temporarily');
redirect($Url->Url);
break;
}
?>