add google analytics

This commit is contained in:
Kacper Donat 2018-10-07 20:23:15 +02:00
parent f72c2ad15e
commit df92ae2dee
3 changed files with 16 additions and 0 deletions

View File

@ -2,6 +2,8 @@
# Copy this file to .env file for development, create environment variables when deploying to production
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
GOOGLE_ANALYTICS=
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=1bdf86cdc78fba654e4f2c309c6bbdbd

View File

@ -2,3 +2,5 @@ twig:
paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
globals:
ga_tracking: "%env(GOOGLE_ANALYTICS)%"

View File

@ -19,6 +19,18 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<title>{% block title %}Czy dojadę?{% endblock %}</title>
{% if ga_tracking %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ ga_tracking }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ ga_tracking }}');
</script>
{% endif %}
</head>
<body>
<main role="main" class="container not-ready" id="app">