Skip to content

Commit

Permalink
Double check that ga variable exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Woodruff authored and Andy Woodruff committed May 12, 2020
1 parent fa4ed30 commit 66b1c5a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/js/stateUpdate/stateUpdateCensusField.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getStateUpdateCensusField = ({ components }) => function updateCensusField
yearDropdown,
} = components;

if (censusField) {
if (censusField && typeof ga !== 'undefined') {
ga('send', 'event', 'data', 'indicator', censusField.id);
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/stateUpdate/stateUpdateIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getStateUpdateIndicator = ({ components }) => function updateIndicator() {
const indicator = this.get('indicator');
const nationalMapData = this.getCurrentNationalMapData();
const nationalData = this.getCurrentNationalData();
if (indicator) {
if (indicator && typeof ga !== 'undefined') {
ga('send', 'event', 'data', 'indicator', indicator.value);
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/stateUpdate/stateUpdateMSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getStateUpdateMSA = ({ components }) => function updateMSA() {
this.set('distanceFilter', null);
const distanceFilter = this.get('distanceFilter');

if (msa) {
if (msa && typeof ga !== 'undefined') {
ga('send', 'event', 'data', 'msa', msa.msaId);
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/stateUpdate/stateUpdateYears.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const getStateUpdateYear = ({ components }) => function updateYears() {
const nationalData = this.getCurrentNationalData();
const agenciesData = this.getCurrentAgenciesData();

if (scale === 'msa' && !censusField.change) {
if (scale === 'msa' && !censusField.change && typeof ga !== 'undefined') {
// send single year for single year census data
ga('send', 'event', 'data', 'years', years[1]);
} else {
} else if (typeof ga !== 'undefined') {
ga('send', 'event', 'data', 'years', years.join('-'));
}

Expand Down

0 comments on commit 66b1c5a

Please sign in to comment.