Skip to content

Commit 66b1c5a

Browse files
Andy WoodruffAndy Woodruff
authored andcommitted
Double check that ga variable exists
#68
1 parent fa4ed30 commit 66b1c5a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/js/stateUpdate/stateUpdateCensusField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const getStateUpdateCensusField = ({ components }) => function updateCensusField
1010
yearDropdown,
1111
} = components;
1212

13-
if (censusField) {
13+
if (censusField && typeof ga !== 'undefined') {
1414
ga('send', 'event', 'data', 'indicator', censusField.id);
1515
}
1616

src/js/stateUpdate/stateUpdateIndicator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getStateUpdateIndicator = ({ components }) => function updateIndicator() {
1111
const indicator = this.get('indicator');
1212
const nationalMapData = this.getCurrentNationalMapData();
1313
const nationalData = this.getCurrentNationalData();
14-
if (indicator) {
14+
if (indicator && typeof ga !== 'undefined') {
1515
ga('send', 'event', 'data', 'indicator', indicator.value);
1616
}
1717

src/js/stateUpdate/stateUpdateMSA.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const getStateUpdateMSA = ({ components }) => function updateMSA() {
1414
this.set('distanceFilter', null);
1515
const distanceFilter = this.get('distanceFilter');
1616

17-
if (msa) {
17+
if (msa && typeof ga !== 'undefined') {
1818
ga('send', 'event', 'data', 'msa', msa.msaId);
1919
}
2020

src/js/stateUpdate/stateUpdateYears.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const getStateUpdateYear = ({ components }) => function updateYears() {
1818
const nationalData = this.getCurrentNationalData();
1919
const agenciesData = this.getCurrentAgenciesData();
2020

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

0 commit comments

Comments
 (0)