Skip to content

Commit

Permalink
Feat(event) - added nonInteraction option
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlen committed Apr 12, 2016
1 parent 4d25637 commit 88cc783
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ this.props.i13n.executeEvent('pageview', {
* `action` - The type of interaction, default set as `click`.
* `label` - Useful for categorizing events, default set as the value of [i13nNode.getText](https://github.com/yahoo/react-i13n/blob/master/docs/api/I13nNode.md#gettexttarget).
* `value` - Values must be non-negative. Useful to pass counts (e.g. 4 times).
* `nonInteraction` - Boolean to indicate a [non-interaction event](https://support.google.com/analytics/answer/1033068#NonInteractionEvents).


You can integrate I13nAnchor provided by react-i13n to track the normal links.
Expand Down
5 changes: 5 additions & 0 deletions index.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ ReactI13nGoogleAnalytics.prototype.getPlugin = function () {
if (model.value) {
params.push(model.value);
}
if (model.nonInteraction) {
params.push({
nonInteraction: true
});
}
params.push({
hitCallback: callback
});
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/index.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ describe('ga plugin client', function () {
it('ga will fire event beacon for click handler', function (done) {
var reactI13nGoogleAnalytics = new ReactI13nGoogleAnalytics('foo');
var tracker = 'myTracker';
var i13nNode = new I13nNode(null, {tracker: tracker, category: 'foo', action: 'bar', label: 'baz', value: 1});
global.ga = function (actionSend, actionName, category, action, label, value, options) {
var i13nNode = new I13nNode(null, {tracker: tracker, category: 'foo', action: 'bar', label: 'baz', nonInteraction: true, value: 1});
global.ga = function (actionSend, actionName, category, action, label, value, fieldsObject, options) {
expect(actionSend).to.eql(tracker + '.send');
expect(actionName).to.eql('event');
expect(category).to.eql('foo');
expect(action).to.eql('bar');
expect(label).to.eql('baz');
expect(value).to.eql(1);
expect(fieldsObject.nonInteraction).to.eql(true);

options.hitCallback && options.hitCallback();
};
reactI13nGoogleAnalytics.getPlugin().eventHandlers.click({
Expand Down

0 comments on commit 88cc783

Please sign in to comment.