Skip to content

Commit

Permalink
Fixed #287 -- Analisar a implementação o código GA-4
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonmoura committed May 13, 2023
1 parent e9414df commit 7f39dd2
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 85 deletions.
4 changes: 2 additions & 2 deletions client/config.php.template
Expand Up @@ -57,8 +57,8 @@ define("OER_DOMAIN","https://pesquisa.bvsalud.org/cvsp"); /* BIREME Accounts con
define("GOOGLE_SCHOLAR","https://scholar.google.com");
define("GOOGLE_SCHOLAR_WS",GOOGLE_SCHOLAR."/scholar?as_q=&as_epq=");

define("GOOGLE_ANALYTICS","");
define("APP_GOOGLE_ANALYTICS","");
define("GOOGLE_ANALYTICS",array());
define("APP_GOOGLE_ANALYTICS",array());

/* Regular Expressions */
define("REGEXP_LANGUAGE","/^(pt|es|en)$/");
Expand Down
43 changes: 26 additions & 17 deletions client/templates/default/header.tpl.php
Expand Up @@ -87,23 +87,32 @@
var PASSWORD_PAGE = "<?php echo $password_page; ?>";
</script>

<?php if ( ! empty(GOOGLE_ANALYTICS) || ! empty(APP_GOOGLE_ANALYTICS) ) : ?>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

if (navigator.userAgent.indexOf('gonative') > -1) {
__gaTracker('create', '<?php echo APP_GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
__gaTracker('set', 'userId', '<?php echo $_SESSION["sysUID"]; ?>'); // Set the user ID using signed-in user_id.
} else {
__gaTracker('create', '<?php echo GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
__gaTracker('set', 'userId', '<?php echo $_SESSION["sysUID"]; ?>'); // Set the user ID using signed-in user_id.
}
</script>
<?php if ( strpos($_SERVER['HTTP_USER_AGENT'], 'gonative') !== false ) : ?>
<?php if ( !empty(APP_GOOGLE_ANALYTICS) ) : ?>
<?php foreach (APP_GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php else : ?>
<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<?php foreach (GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>

<?php $body_class = ( !$_SESSION['userTK'] ) ? 'bodyLogin' : ''; ?>
Expand Down
41 changes: 26 additions & 15 deletions client/templates/myvhl/header.tpl.php
Expand Up @@ -86,21 +86,32 @@
var PASSWORD_PAGE = "<?php echo $password_page; ?>";
</script>

<?php if ( ! empty(GOOGLE_ANALYTICS) || ! empty(APP_GOOGLE_ANALYTICS) ) : ?>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

if (navigator.userAgent.indexOf('gonative') > -1) {
__gaTracker('create', '<?php echo APP_GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
} else {
__gaTracker('create', '<?php echo GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
}
</script>
<?php if ( strpos($_SERVER['HTTP_USER_AGENT'], 'gonative') !== false ) : ?>
<?php if ( !empty(APP_GOOGLE_ANALYTICS) ) : ?>
<?php foreach (APP_GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php else : ?>
<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<?php foreach (GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>

<?php $body_class = ( !$_SESSION['userTK'] && !$public ) ? 'main_page' : ''; ?>
Expand Down
4 changes: 2 additions & 2 deletions server/config.php.template
Expand Up @@ -58,8 +58,8 @@ define("VHL_SEARCH_PORTAL_DOMAIN","https://pesquisa.bvsalud.org");
define("BVS_COOKIE_DOMAIN","https://brasil.bvs.br");
define("MONGODB_SERVER","");

define("GOOGLE_ANALYTICS","");
define("APP_GOOGLE_ANALYTICS","");
define("GOOGLE_ANALYTICS",array());
define("APP_GOOGLE_ANALYTICS",array());

/* Regular Expressions */
define("REGEXP_LANGUAGE","/^(pt|es|en)$/");
Expand Down
43 changes: 26 additions & 17 deletions server/templates/default/header-eblueinfo.tpl.php
Expand Up @@ -31,23 +31,32 @@
var LANG = "<?php echo $_SESSION['lang'] ? $_SESSION['lang'] : DEFAULT_LANG; ?>";
</script>

<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

if (navigator.userAgent.indexOf('gonative') > -1) {
__gaTracker('create', '<?php echo APP_GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
__gaTracker('set', 'userId', '<?php echo $_SESSION["sysUID"]; ?>'); // Set the user ID using signed-in user_id.
} else {
__gaTracker('create', '<?php echo GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
__gaTracker('set', 'userId', '<?php echo $_SESSION["sysUID"]; ?>'); // Set the user ID using signed-in user_id.
}
</script>
<?php if ( strpos($_SERVER['HTTP_USER_AGENT'], 'gonative') !== false ) : ?>
<?php if ( !empty(APP_GOOGLE_ANALYTICS) ) : ?>
<?php foreach (APP_GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php else : ?>
<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<?php foreach (GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
</head>
<body>
Expand Down
43 changes: 26 additions & 17 deletions server/templates/default/header.tpl.php
Expand Up @@ -76,23 +76,32 @@
var PASSWORD_PAGE = "<?php echo $password_page; ?>";
</script>

<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

if (navigator.userAgent.indexOf('gonative') > -1) {
__gaTracker('create', '<?php echo APP_GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
__gaTracker('set', 'userId', '<?php echo $_SESSION["sysUID"]; ?>'); // Set the user ID using signed-in user_id.
} else {
__gaTracker('create', '<?php echo GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
__gaTracker('set', 'userId', '<?php echo $_SESSION["sysUID"]; ?>'); // Set the user ID using signed-in user_id.
}
</script>
<?php if ( strpos($_SERVER['HTTP_USER_AGENT'], 'gonative') !== false ) : ?>
<?php if ( !empty(APP_GOOGLE_ANALYTICS) ) : ?>
<?php foreach (APP_GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php else : ?>
<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<?php foreach (GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>

<?php $body_class = ( !$_SESSION['userTK'] ) ? 'bodyLogin' : ''; ?>
Expand Down
41 changes: 26 additions & 15 deletions server/templates/myvhl/header.tpl.php
Expand Up @@ -65,21 +65,32 @@
var PASSWORD_PAGE = "<?php echo $password_page; ?>";
</script>

<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

if (navigator.userAgent.indexOf('gonative') > -1) {
__gaTracker('create', '<?php echo APP_GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
} else {
__gaTracker('create', '<?php echo GOOGLE_ANALYTICS; ?>', 'auto');
__gaTracker('send', 'pageview');
}
</script>
<?php if ( strpos($_SERVER['HTTP_USER_AGENT'], 'gonative') !== false ) : ?>
<?php if ( !empty(APP_GOOGLE_ANALYTICS) ) : ?>
<?php foreach (APP_GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php else : ?>
<?php if ( !empty(GOOGLE_ANALYTICS) ) : ?>
<?php foreach (GOOGLE_ANALYTICS as $ga_code) : ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $ga_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $ga_code; ?>');
</script>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>

<?php $lang_class = ( $_SESSION['lang'] ) ? 'body_'.$_SESSION['lang'] : 'body_pt'; ?>
Expand Down

0 comments on commit 7f39dd2

Please sign in to comment.