Commit 24cdd33c authored by José Bascuñan's avatar José Bascuñan

Merge branch '11-incorporar-google-tag-manager-en-vez-de-google-analytics' into 'develop'

se agrega google_tag_manager_code

See merge request super/misuper!17
parents 21ddcd6a 8a20f779
Pipeline #7651 passed with stages
in 8 minutes and 43 seconds
......@@ -18,6 +18,7 @@ EMAIL_USE_TLS=
ALLOWED_HOSTS=localhost
GOOGLE_ANALYTICS_CODE=
GOOGLE_TAG_MANAGER_CODE=
RECAPTCHA_PUBLIC_KEY=
RECAPTCHA_PUBLIC_KEY=
......
......@@ -11,6 +11,14 @@ doctype 5
html(lang="es")
head
if google_tag_manager_code
script.
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{google_tag_manager_code}}');
// version=1.0.2
if google_analytics_code
// Global site tag (gtag.js) - Google Analytics
......@@ -145,6 +153,9 @@ html(lang="es")
block stylesheets
body(class='{{body_class|default:""}}')
noscript
iframe(src='https://www.googletagmanager.com/ns.html?id=', height='0', width='0', style='display:none;visibility:hidden')
{% cms_toolbar %}
header
{% include 'includes/navbar.pug' %}
......
......@@ -8,6 +8,12 @@ def google_analytics_code(request):
'site': Site.objects.get_current(),
}
def google_tag_manager_code(request):
return {
'google_tag_manager_code': settings.GOOGLE_TAG_MANAGER_CODE,
'site': Site.objects.get_current(),
}
def google_maps_token(request):
return {
......
......@@ -33,6 +33,7 @@ LOCALLY_ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost').split(',')
ADMINS = eval(os.getenv('ADMINS')) if os.getenv('ADMINS') else ()
GOOGLE_ANALYTICS_CODE = os.getenv('GOOGLE_ANALYTICS_CODE')
GOOGLE_TAG_MANAGER_CODE = os.getenv('GOOGLE_TAG_MANAGER_CODE')
GOOGLE_MAPS_TOKEN= os.getenv('GOOGLE_MAPS_TOKEN')
SECRET_KEY = os.getenv('SECRET_KEY', 'CHANGE ME')
......
......@@ -43,6 +43,7 @@ def get_local_value(key, default_value=None):
return default_value
GOOGLE_ANALYTICS_CODE = get_local_value('GOOGLE_ANALYTICS_CODE', None)
GOOGLE_TAG_MANAGER_CODE = get_local_value('GOOGLE_TAG_MANAGER_CODE', None)
GOOGLE_MAPS_TOKEN = get_local_value('GOOGLE_MAPS_TOKEN')
# default keys, replace with somethign your own
......@@ -262,7 +263,8 @@ TEMPLATES = [
'cms.context_processors.cms_settings',
'sekizai.context_processors.sekizai',
'project.context_processors.google_analytics_code',
'project.context_processors.google_maps_token',
'project.context_processors.google_tag_manager_code',
'project.context_processors.google_maps_token',
],
'loaders': [
('pypugjs.ext.django.Loader', (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment