Skip to content

Commit

Permalink
Move GA4 tracking code to <head>
Browse files Browse the repository at this point in the history
  • Loading branch information
melaniekung committed Sep 5, 2024
1 parent e503a1f commit 5c51050
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 12 deletions.
12 changes: 0 additions & 12 deletions apps/qubit/templates/_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,3 @@
</div>

</footer>

<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
11 changes: 11 additions & 0 deletions apps/qubit/templates/layout.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<?php echo get_component('default', 'tagManager', ['code' => 'script']); ?>
<?php include_http_metas(); ?>
<?php include_metas(); ?>
Expand Down
11 changes: 11 additions & 0 deletions apps/qubit/templates/layout_1col.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<?php echo get_component('default', 'tagManager', ['code' => 'script']); ?>
<?php include_http_metas(); ?>
<?php include_metas(); ?>
Expand Down
11 changes: 11 additions & 0 deletions apps/qubit/templates/layout_2col.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<?php echo get_component('default', 'tagManager', ['code' => 'script']); ?>
<?php include_http_metas(); ?>
<?php include_metas(); ?>
Expand Down
11 changes: 11 additions & 0 deletions apps/qubit/templates/layout_3col.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<?php echo get_component('default', 'tagManager', ['code' => 'script']); ?>
<?php include_http_metas(); ?>
<?php include_metas(); ?>
Expand Down
11 changes: 11 additions & 0 deletions apps/qubit/templates/layout_basic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<?php echo get_component('default', 'tagManager', ['code' => 'script']); ?>
<?php include_http_metas(); ?>
<?php include_metas(); ?>
Expand Down
11 changes: 11 additions & 0 deletions apps/qubit/templates/layout_wide.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<?php echo get_component('default', 'tagManager', ['code' => 'script']); ?>
<?php include_http_metas(); ?>
<?php include_metas(); ?>
Expand Down
11 changes: 11 additions & 0 deletions plugins/arDominionB5Plugin/templates/_layout_start_webpack.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<!DOCTYPE html>
<html lang="<?php echo $sf_user->getCulture(); ?>" dir="<?php echo sfCultureInfo::getInstance($sf_user->getCulture())->direction; ?>">
<head>
<?php $gaKey = sfConfig::get('app_google_analytics_api_key', ''); ?>
<?php if (!empty($gaKey)) { ?>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?> async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $gaKey; ?>"></script>
<script <?php echo __(sfConfig::get('csp_nonce', '')); ?>>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<?php include_slot('google_analytics'); ?>
gtag('config', '<?php echo $gaKey; ?>');
</script>
<?php } ?>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php include_title(); ?>
Expand Down

0 comments on commit 5c51050

Please sign in to comment.