Skip to content

Commit

Permalink
Revert GTM changes.
Browse files Browse the repository at this point in the history
The changes are OK but they haven't made their way to SCL3 prod yet. Reverting
to keep the codebases close and so that we can track using GA on both.

Revert "Preserved legacy trackEvent function, added analytics.js back to bundle"

This reverts commit 1331ca1.

Revert "[fix bug 1431412] Replace GA script with GTM."

This reverts commit 33be297.
  • Loading branch information
glogiotatidis committed Mar 19, 2018
1 parent 433dcf0 commit 990a8b4
Show file tree
Hide file tree
Showing 34 changed files with 381 additions and 170 deletions.
1 change: 0 additions & 1 deletion .env-dist
Expand Up @@ -11,4 +11,3 @@ ES_URLS=elasticsearch:9200
SESSION_COOKIE_SECURE=False
SECRET_KEY=secret
DEBUG=True
GTM_CONTAINER_ID=
10 changes: 3 additions & 7 deletions kitsune/bundles.py
Expand Up @@ -293,6 +293,7 @@
'sumo/js/geoip-locale.js',
'mailcheck/src/mailcheck.js',
'sumo/js/ui.js',
'sumo/js/dnt-helper.js',
'sumo/js/analytics.js',
'sumo/js/surveygizmo.js',
'sumo/js/instant_search.js',
Expand Down Expand Up @@ -350,6 +351,7 @@
},
'mobile-common': {
'source_filenames': (
'sumo/js/dnt-helper.js',
'sumo/js/templates/mobile-search-results.js',
'moment/moment.js',
'sumo/js/i18n.js',
Expand Down Expand Up @@ -544,6 +546,7 @@
'modernizr/modernizr.js',
'sumo/js/browserdetect.js',
'sumo/js/mobile/ui.js',
'sumo/js/dnt-helper.js',
'sumo/js/analytics.js',
'sumo/js/libs/jquery.cookie.js',
'sumo/js/libs/jquery.lazyload.js',
Expand Down Expand Up @@ -644,11 +647,4 @@
),
'output_filename': 'build/experiment-fxa-cta-topbar-min.js'
},
'gtm-snippet': {
'source_filenames': (
'sumo/js/dnt-helper.js',
'sumo/js/gtm-snippet.js',
),
'output_filename': 'build/gtm-snippet-min.js'
},
}
Expand Up @@ -6,10 +6,10 @@
<form method="post" action="{{ url('users.make_contributor') }}">
<input type="hidden" name="return_to" value="{{ request.get_full_path() }}">
{% csrf_token %}
<button id="sign-up-contributor" class="btn btn-submit" data-event-category="Sign Me Up Click" data-event-action="Logged In">{{ _('Sign me up') }} &raquo;</button>
<button id="sign-up-contributor" class="btn btn-submit" data-ga-click="_trackEvent | Sign Me Up Click | Logged In">{{ _('Sign me up') }} &raquo;</button>
</form>
{% else %}
<a id="sign-up-contributor" class="btn btn-submit" href="{{ url('users.auth_contributor') }}" data-event-category="Sign Me Up Click" data-event-action="Logged Out">
<a id="sign-up-contributor" class="btn btn-submit" href="{{ url('users.auth_contributor') }}" data-ga-click="_trackEvent | Sign Me Up Click | Logged Out">
{{ _('Sign me up') }} &raquo;
</a>
{% endif %}
Expand Down
6 changes: 2 additions & 4 deletions kitsune/products/jinja2/products/documents.html
Expand Up @@ -57,8 +57,7 @@ <h2 class="topic-description cf">
{# only show subtopics on the parent topic page #}
{% for subtopic in subtopics %}
<li class="subtopic">
<a href="{{ url('products.subtopics', product_slug=product.slug, topic_slug=topic.slug, subtopic_slug=subtopic.slug) }}"
data-event-category="link click" data-event-action="subtopic" data-event-label="{{ subtopic.title }}">
<a href="{{ url('products.subtopics', product_slug=product.slug, topic_slug=topic.slug, subtopic_slug=subtopic.slug) }}">
{{ pgettext('DB: products.Topic.title', subtopic.title) }}
</a>
{% if subtopic.title != subtopic.description %}
Expand All @@ -69,8 +68,7 @@ <h2 class="topic-description cf">
{% endif %}
{% for document in documents %}
<li>
<a href="{{ document['url'] }}" data-event-category="link click" data-event-action="document"
data-event-label="{{ document['document_title'] }}">{{ document['document_title'] }}</a>
<a href="{{ document['url'] }}">{{ document['document_title'] }}</a>
{{ document['document_summary'] }}
</li>
{% endfor %}
Expand Down
Expand Up @@ -7,7 +7,7 @@
{% else %}
{% set prod_url = url('products.product', slug=product.slug) %}
{% endif %}
<a class="cf" href="{{ prod_url }}" data-event-category="link click" data-event-action="product" data-event-label="{{ product.title }}">
<a class="cf" href="{{ prod_url }}">
<img src="{{ STATIC_URL }}sumo/img/blank.png" class="logo-sprite" style="{% if product.image and product.image_offset %}background-image: url({{ product.sprite_url() }}); background-position: -100px -{{ 100 + (product.image_offset * 296) }}px;{% else %}background-image: url({{ product.image_url }}){% endif %}" alt="" />
<span class="title">{{ pgettext('DB: products.Product.title', product.title) }}</span>
<span class="description">{{ pgettext('DB: products.Product.description', product.description) }}</span>
Expand Down
8 changes: 4 additions & 4 deletions kitsune/products/jinja2/products/includes/topic_macros.html
Expand Up @@ -3,15 +3,15 @@
{% if loop.first %}<ul class="card-grid cf">{% endif %}
<li>
{% set topic_url = url('products.documents', product_slug=product.slug, topic_slug=topic.slug) %}
<a href="{{ topic_url }}" class="cf" data-event-category="link click" data-event-action="topic" data-event-label="{{topic.title}}">
<a href="{{ topic_url }}" class="cf">
<img src="{{ STATIC_URL }}sumo/img/blank.png" class="topic-icon" style="background-image: url('{{ topic.image_url }}')" alt="" />
<span class="title">{{ pgettext('DB: products.Topic.title', topic.title) }}</span>
</a>
</li>
{% if loop.last %}
{% if show_community_support %}
<li class="community-support">
<a href="{{ url('wiki.document', 'get-community-support') }}" class="cf" data-event-category="link click" data-event-action="topic" data-event-label="Get community support">
<a href="{{ url('wiki.document', 'get-community-support') }}" class="cf">
<img src="{{ STATIC_URL }}sumo/img/blank.png" class="topic-icon" alt="" />
<span class="title">{{ _('Get community support') }}</span>
</a>
Expand All @@ -27,15 +27,15 @@
{% for topic in topics %}
{% set topic_url = url('products.documents', product_slug=product.slug, topic_slug=topic.slug) %}
<li {% if selected_topic == topic %}class="selected {% if selected_subtopic != None %}subtopic-selected{% endif %}"{% endif %}>
<a href="{{ topic_url }}" data-event-category="link click" data-event-action="topic sidebar" data-event-label="{{topic.title}}">
<a href="{{ topic_url }}">
{{ pgettext('DB: products.Topic.title', topic.title) }}
</a>
{% if selected_topic == topic %}
<ul class="subtopics">
{% for subtopic in subtopics %}
{% set subtopic_url = url('products.subtopics', product_slug=product.slug, topic_slug=topic.slug, subtopic_slug=subtopic.slug) %}
<li {{ selected_subtopic|class_selected(subtopic) }}>
<a href="{{ subtopic_url }}" data-event-category="link click" data-event-action="subtopic sidebar" data-event-label="{{subtopic.title}}">
<a href="{{ subtopic_url }}">
{{ pgettext('DB: products.Topic.title', subtopic.title) }}
</a>
</li>
Expand Down
6 changes: 2 additions & 4 deletions kitsune/products/jinja2/products/mobile/documents.html
Expand Up @@ -38,17 +38,15 @@
{# only show subtopics on the parent topic page #}
{% for subtopic in subtopics %}
<li>
<a href="{{ url('products.subtopics', product_slug=product.slug, topic_slug=topic.slug, subtopic_slug=subtopic.slug) }}"
data-event-category="link click" data-event-action="subtopic" data-event-label="{{ subtopic.title }}">
<a href="{{ url('products.subtopics', product_slug=product.slug, topic_slug=topic.slug, subtopic_slug=subtopic.slug) }}">
{{ pgettext('DB: products.Topic.title', subtopic.title) }}
</a>
</li>
{% endfor %}
{% endif %}
{% for document in documents %}
<li>
<a class="cf" href="{{ document['url'] }}" data-event-category="link click"
data-event-action="document" data-event-label="{{ document['document_title'] }}">{{ document['document_title'] }}</a>
<a class="cf" href="{{ document['url'] }}">{{ document['document_title'] }}</a>
</li>
{% endfor %}
{% if product.questions_enabled(request.LANGUAGE_CODE) %}
Expand Down
6 changes: 2 additions & 4 deletions kitsune/products/jinja2/products/mobile/product.html
Expand Up @@ -16,16 +16,14 @@
<ul id="topics">
{% for topic in topics %}
<li>
<a href="{{ url('products.documents', product_slug=product.slug, topic_slug=topic.slug) }}" class="cf"
data-event-category="link click" data-event-action="topic" data-event-label="{{ topic.title }}">
<a href="{{ url('products.documents', product_slug=product.slug, topic_slug=topic.slug) }}" class="cf">
<img src="{{ STATIC_URL }}sumo/img/blank.png" class="topic-sprite topic-{{ topic.slug }}" alt="">
{{ pgettext('DB: products.Topic.title', topic.title) }}
</a>
</li>
{% if loop.last %}
<li>
<a href="{{ url('wiki.document', 'get-community-support') }}" class="cf"
data-event-category="link click" data-event-action="topic" data-event-label="Get community support">
<a href="{{ url('wiki.document', 'get-community-support') }}" class="cf">
<img src="{{ STATIC_URL }}sumo/img/blank.png" class="topic-sprite topic-get-community-support" alt="">
{{ _('Get community support') }}
</a>
Expand Down
2 changes: 1 addition & 1 deletion kitsune/products/jinja2/products/mobile/products.html
Expand Up @@ -8,7 +8,7 @@
<ul id="products">
{% for product in products %}
<li>
<a class="cf" href="{{ url('products.product', slug=product.slug) }}" data-event-category="link click" data-event-action="product" data-event-label="{{ product.title }}">
<a class="cf" href="{{ url('products.product', slug=product.slug) }}">
<img src="{{ STATIC_URL }}sumo/img/blank.png" class="logo-sprite" {% if product.image and product.image_offset %}style="background-position: -50px -{{ 50 + (product.image_offset * 148) }}px;"{% endif %} alt="">
<span class="title">{{ pgettext('DB: products.Product.title', product.title) }}</span>
{{ pgettext('DB: products.Product.description', product.description) }}
Expand Down
15 changes: 6 additions & 9 deletions kitsune/products/jinja2/products/product.html
Expand Up @@ -22,9 +22,8 @@ <h1 class="product-title cf">
{% if product.slug == 'firefox' %}
<div class="download-firefox">
<a href="https://www.mozilla.org/firefox/new/#download-fx" class="download-button"
data-event-category="Download Button"
data-event-action="Panel Opening"
data-event-label="{{ latest_version }}">
data-ga-click="_trackEvent | Download Button | Panel Opening"
data-latest-version="{{ latest_version }}">
<span class="download-content">
<strong class="download-title">{{ _('Firefox') }}</strong>
<span class="download-subtitle">{{ _('Free Download') }}</span>
Expand All @@ -46,19 +45,17 @@ <h1 class="product-title cf">
{{ _('How does it work?') }}
</a>
<a href="https://www.mozilla.org/firefox/new/#download-fx"
data-event-category="Download Button"
data-event-action="Panel Opening"
data-event-label="{{ latest_version }}">
{{ _('Download a fresh copy') }}
data-ga-click="_trackEvent | Download Button | Panel Opening"
data-latest-version="{{ latest_version }}">
{{ _('Download a fresh copy') }}
</a>
</div>
{% endif %}

{% if product.slug == 'thunderbird' %}
<div class="download-thunderbird">
<a href="https://www.mozilla.org/thunderbird" class="download-button"
data-event-category="Download Button"
data-event-action="Download Thunderbird">
data-ga-click="_trackEvent | Download Button | Download Thunderbird">
<span class="download-content">
<strong class="download-title">{{ _('Thunderbird') }}</strong>
<span class="download-subtitle">{{ _('Free Download') }}</span>
Expand Down
10 changes: 2 additions & 8 deletions kitsune/questions/jinja2/questions/includes/aaq_macros.html
Expand Up @@ -22,10 +22,7 @@ <h2>{{ _('Which product would you like to post a question about?') }}</h2>
<ul id="product-picker" class="card-grid cf">
{% for key, product in products.iteritems() %}
<li>
<a class="cf" href="{{ url('questions.aaq_step2', product_key=key) }}"
data-event-category="link click"
data-event-action="product"
data-event-label="{{ product.name }}">
<a class="cf" href="{{ url('questions.aaq_step2', product_key=key) }}">
<img src="{{ STATIC_URL }}sumo/img/blank.png" alt="" class="logo-sprite logo-{{ key }}">
<span class="title">{{ product.name }}</span>
<span class="description">{{ product.subtitle }}</span>
Expand All @@ -51,10 +48,7 @@ <h2>{{ _('Which category best describes your problem?') }}</h2>
<ul class="select-one">
{% for key, category in product.categories.iteritems() %}
<li>
<a href="{{ url('questions.aaq_step3', product_key=product.key, category_key=key) }}"
data-event-category="link click"
data-event-action="category"
data-event-label="{{ category.name }}">{{ category.name }}</a>
<a href="{{ url('questions.aaq_step3', product_key=product.key, category_key=key) }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
Expand Down
3 changes: 1 addition & 2 deletions kitsune/questions/jinja2/questions/mobile/new_question.html
Expand Up @@ -25,8 +25,7 @@ <h2>{{ _('Products') }}</h2>
<ul>
{% for key, product in products.iteritems() %}
<li class="{% if product == current_product %}selected{% endif %}">
<a href="{{ url('questions.aaq_step2', product_key=key) }}" data-event-category="link click"
data-event-action="product" data-event-label="{{ product.name }}">
<a href="{{ url('questions.aaq_step2', product_key=key) }}">
<span class="logo-sprite logo-{{ key }}"></span>
{{ product.name }}
</a>
Expand Down
4 changes: 2 additions & 2 deletions kitsune/questions/jinja2/questions/new_question.html
Expand Up @@ -67,7 +67,7 @@ <h2 class="no-results">{{ _('This question has not been asked before.') }}</h2>
<input type="hidden" name="search" value="{{ request.GET.search }}" />
<input type="hidden" name="step" value="{% if user.is_authenticated() %}aaq-question{% else %}aaq-register{% endif %}" />
{% set ga_action = 'pre-registered question' if user.is_authenticated() else 'step 1 link' %}
<button type="submit" data-event-category="Ask A Question Flow" data-event-action="{{ ga_action }}" class="btn btn-submit big">
<button type="submit" data-ga-click="_trackEvent | Ask A Question Flow | {{ ga_action }}" class="btn btn-submit big">
{{ button_text }}
</button>
</form>
Expand All @@ -80,4 +80,4 @@ <h2>{{ _('Ask your question to our community of users') }}</h2>
{% endblock %}

{% block submit_button_value %}{{ _('Post Question') }}{% endblock %}
{% block submit_button_attrs %}data-event-category="Ask A Question Flow" data-event-action="step 3 link"{% endblock %}
{% block submit_button_attrs %}data-ga-click="_trackEvent | Ask A Question Flow | step 3 link"{% endblock %}
2 changes: 1 addition & 1 deletion kitsune/questions/jinja2/questions/new_question_login.html
Expand Up @@ -13,4 +13,4 @@
{% endblock %}

{% block submit_button_value %}{{ _('Post Question') }}{% endblock %}
{% block submit_button_attrs %}data-event-category="Ask A Question Flow" data-event-action="step 3 link"{% endblock %}
{% block submit_button_attrs %}data-ga-click="_trackEvent | Ask A Question Flow | step 3 link"{% endblock %}
Expand Up @@ -107,7 +107,7 @@ class SuggestionItem extends React.Component {
<li className={classString}>
<a
href={suggestion.url}
data-event-category="Ask A Question Flow - SPA" data-event-action="suggested article selected"
data-ga-click="_trackEvent | Ask A Question Flow - SPA | suggested article selected"
>
{suggestion.title}
</a>
Expand Down
4 changes: 4 additions & 0 deletions kitsune/search/jinja2/search/mobile/results.html
Expand Up @@ -5,6 +5,10 @@
{% set classes = 'results' %}
{% set styles = ('mobile-search',) %}

{% if num_results == 0 %}
{% set ga_push = [['_trackEvent', 'Zero Search Results', q]] %}
{% endif %}

{% block after_header %}
<div class="search-bar slide-on-exposed">
{{ mobile_results_form(q, search_params) }}
Expand Down
4 changes: 4 additions & 0 deletions kitsune/search/jinja2/search/results.html
Expand Up @@ -4,6 +4,10 @@
{% from "search/includes/macros.html" import basic_search_form with context %}
{% set meta = (('WT.oss', q), ('WT.oss_r', num_results), ('robots', 'noindex')) %}

{% if num_results == 0 %}
{% set ga_push = [['_trackEvent', 'Zero Search Results', q]] %}
{% endif %}

{% if advanced %}
{% set title = _('Advanced Search Results') %}
{% set crumbs = [(url('search.advanced'), _('Advanced Search')), (None, _('Results'))] %}
Expand Down
20 changes: 20 additions & 0 deletions kitsune/search/tests/test_search_simple.py
Expand Up @@ -109,6 +109,26 @@ def test_clean_question_excerpt(self):
doc = pq(response.content)
assert 'script' not in doc('div.result').text()

def test_ga_zero_results_event(self):
"""If there are no results, verify ga-push data attr on body."""
doc = DocumentFactory(title=u'audio', locale=u'en-US', category=10)
doc.products.add(ProductFactory(title=u'firefox', slug=u'desktop'))
RevisionFactory(document=doc, is_approved=True)

self.refresh()

# If there are results, data-ga-push should be an empty list.
response = self.client.get(reverse('search'), {'q': 'audio'})
eq_(200, response.status_code)
doc = pq(response.content)
eq_('[]', doc('body').attr('data-ga-push'))

# If there are no results, then Zero Search Results event is there.
response = self.client.get(reverse('search'), {'q': 'piranha'})
eq_(200, response.status_code)
doc = pq(response.content)
assert '"Zero Search Results"' in doc('body').attr('data-ga-push')

def test_fallback_for_zero_results(self):
"""If there are no results, fallback to a list of top articles."""
firefox = ProductFactory(title=u'firefox', slug=u'desktop')
Expand Down
1 change: 0 additions & 1 deletion kitsune/settings.py
Expand Up @@ -967,7 +967,6 @@ def JINJA_CONFIG():
GA_ACCOUNT = config('GA_ACCOUNT', 'something@developer.gserviceaccount.com') # Google API Service Account email address
GA_PROFILE_ID = config('GA_PROFILE_ID', default='12345678') # Google Analytics profile id for SUMO prod
GA_START_DATE = date(2012, 11, 10)
GTM_CONTAINER_ID = config('GTM_CONTAINER_ID', default='') # Google container ID

MOBILE_COOKIE = config('MOBILE_COOKIE', default='msumo')

Expand Down

0 comments on commit 990a8b4

Please sign in to comment.