se agrega google_tag_manager_code

parent 36078084
Pipeline #7649 passed with stages
in 16 minutes and 29 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' %}
......
......@@ -7,3 +7,16 @@ def google_analytics_code(request):
'google_analytics_code': settings.GOOGLE_ANALYTICS_CODE,
'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 {
'google_maps_token': settings.GOOGLE_MAPS_TOKEN,
'site': Site.objects.get_current(),
}
......@@ -33,6 +33,8 @@ 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')
......
......@@ -42,8 +42,9 @@ def get_local_value(key, default_value=None):
except AttributeError:
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
RECAPTCHA_PUBLIC_KEY = get_local_value('RECAPTCHA_PUBLIC_KEY', None)
......@@ -262,6 +263,8 @@ TEMPLATES = [
'cms.context_processors.cms_settings',
'sekizai.context_processors.sekizai',
'project.context_processors.google_analytics_code',
'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