Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adicionando google tag manager #21

Merged
merged 1 commit into from
Mar 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ heroku config:set 'SECRET_KEY=VALOR-RANDOMICO-QUE-O-STARTPROJECT-GERA-PRA-VC'
heroku config:set DEBUG=False
heroku config:set 'RECAPTCHA_PUBLIC_KEY=CHAVE-PUBLICA-DO-RECAPTCHA'
heroku config:set 'RECAPTCHA_PRIVATE_KEY=CHAVE-PRIVADA-DO-RECAPTCHA'
heroku config:set 'GTM_CONTAINER=CONTAINER-DO-GOOGLE-TAG-MANAGER'
git push heroku master
heroku run python manage.py syncdb --migrate
```
Expand All @@ -43,3 +44,6 @@ heroku run python manage.py syncdb --migrate

#Gerar credenciais do reCaptcha
Para gerar as credenciais do reCaptcha acesse http://www.google.com/recaptcha

#Configurar o Google Tag Manager
Através do Google Tag Manager é possível configurar o Google Analytics e outras ferramentas externas. Para configurar uma conta acesse: https://www.google.com/tagmanager
7 changes: 7 additions & 0 deletions telemob/main/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-

from django.conf import settings


def google_tag_manager(request):
return {'GTM_CONTAINER': settings.GTM_CONTAINER}
7 changes: 7 additions & 0 deletions telemob/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'telemob.main.context_processors.google_tag_manager'
)

TEMPLATE_DIRS = (
Expand All @@ -115,6 +116,12 @@
default='1234567897132123'
)

# Google Tag Manager
GTM_CONTAINER = config(
'GTM_CONTAINER',
default=None
)

RECAPTCHA_PRIVATE_KEY = config(
'RECAPTCHA_PRIVATE_KEY',
default='1234567897132123'
Expand Down
13 changes: 13 additions & 0 deletions telemob/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>

{% if GTM_CONTAINER %}
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={{ GTM_CONTAINER }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{ GTM_CONTAINER }}');</script>
<!-- End Google Tag Manager -->
{% endif %}

{% block js %}{% endblock js %}
</body>
</html>