Skip to content

Commit

Permalink
update js tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
kr8n3r committed Nov 1, 2019
1 parent 38240a9 commit 30f77c5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/assets/javascripts/live_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
window.ga('set', 'transport', 'beacon')
}

// track impressions of spelling suggestions
if (this.$suggestionsBlock) {
this.trackSpellingSuggestionsImpressions(this.$suggestionsBlock)
}

if (GOVUK.support.history()) {
this.saveState()

Expand Down Expand Up @@ -151,9 +146,11 @@
}

LiveSearch.prototype.trackSpellingSuggestionsImpressions = function trackSpellingSuggestionsImpressions ($suggestions) {
$($suggestions).find('a').each(function () {
GOVUK.SearchAnalytics.setDimension(81, $(this).data('track-options').dimension81)
})
var $spellingSuggestionMetaTag = $("meta[name='govuk:spelling-suggestion']")
// currently there's ever only one suggestion
var spellingSuggestionAvailable = this.$suggestionsBlock.find('a').length > 0
var suggestion = spellingSuggestionAvailable ? this.$suggestionsBlock.find('a').data('track-options').dimension81 : ''
$spellingSuggestionMetaTag.attr('content', suggestion)
}

/**
Expand Down

0 comments on commit 30f77c5

Please sign in to comment.