Skip to content

Commit

Permalink
Merge pull request #21 from arloc/google_tag_manager
Browse files Browse the repository at this point in the history
Adicionando google tag manager
  • Loading branch information
ramalho committed Mar 18, 2014
2 parents 33b375d + 0972495 commit c25eb90
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
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>

0 comments on commit c25eb90

Please sign in to comment.