Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Commit e24fb5b

Browse files
committed
Merge pull request #26 from segment-integrations/fix-category
Changed props.category to track.category()
2 parents 093c529 + 15e0cb2 commit e24fb5b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ GA.prototype.track = function(track, options) {
261261

262262
var payload = {
263263
eventAction: track.event(),
264-
eventCategory: props.category || this._category || 'All',
264+
eventCategory: track.category() || this._category || 'All',
265265
eventLabel: props.label,
266266
eventValue: formatValue(props.value || track.revenue()),
267267
nonInteraction: !!(props.nonInteraction || opts.nonInteraction)
@@ -424,7 +424,7 @@ GA.prototype.trackClassic = function(track, options) {
424424
var props = track.properties();
425425
var revenue = track.revenue();
426426
var event = track.event();
427-
var category = this._category || props.category || 'All';
427+
var category = this._category || track.category() || 'All';
428428
var label = props.label;
429429
var value = formatValue(revenue || props.value);
430430
var nonInteraction = !!(props.nonInteraction || opts.nonInteraction);

test/index.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,17 @@ describe('Google Analytics', function() {
455455
});
456456
});
457457

458+
it('should send an event and map category with a capital C', function() {
459+
analytics.track('event', {Category: 'blah'});
460+
analytics.called(window.ga, 'send', 'event', {
461+
eventCategory: 'blah',
462+
eventAction: 'event',
463+
eventLabel: undefined,
464+
eventValue: 0,
465+
nonInteraction: false
466+
});
467+
});
468+
458469
it('should send an event with context', function() {
459470
analytics.track('event', {}, {
460471
campaign: {

0 commit comments

Comments
 (0)