Skip to content

Commit

Permalink
Merge pull request #2947 from fecgov/feature/2802-aggregate-totals-wi…
Browse files Browse the repository at this point in the history
…dget-analytics

Add analytics
  • Loading branch information
lbeaufort committed Jun 28, 2019
2 parents 961f3e2 + 9d73bff commit f67b94f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions fec/fec/static/js/widgets/aggregate-totals-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ AggregateTotalsBox.prototype.refreshYearsSelect = function() {
} else {
this.yearControl.fireEvent('onchange');
}

logUsage(this.baseQuery.office, this.baseQuery.election_year);
};

/**
Expand Down Expand Up @@ -707,4 +709,20 @@ function buildElement(callingInstance, scriptElement) {
return toReturn;
}

/**
* Handles the usage analytics for this module
* @todo - Decide how to gather usage insights while embedded
* @param {String} officeAbbrev - The user-selected election office
* @param {*} electionYear - String or Number, the user-selected election year
*/
function logUsage(officeAbbrev, electionYear) {
if (window.ga) {
window.ga('send', 'event', {
eventCategory: 'Widget-AggregateTotals',
eventAction: 'interaction',
eventLabel: officeAbbrev + ',' + electionYear
});
}
}

new AggregateTotalsBox();

0 comments on commit f67b94f

Please sign in to comment.