Skip to content

More configuration options when initializing ga#18

Open
Soulou wants to merge 1 commit intopgrippi:masterfrom
Soulou:custom_analitycs_js_statements
Open

More configuration options when initializing ga#18
Soulou wants to merge 1 commit intopgrippi:masterfrom
Soulou:custom_analitycs_js_statements

Conversation

@Soulou
Copy link

@Soulou Soulou commented May 18, 2016

I needed to add more configuration statements in my Analytics initialization, so here is my implementation

ENV.googleAnalytics = {
      webPropertyId: process.env.GOOGLE_ANALYTICS_ID,
      extraCreateParams: {"allowLinker": true},
      extraRequires: ["linker"],
      extraStatements: [{
        action: "linker:autoLink",
        args: ["arg1", {arg2: val2}]
      }]
};

Will result in

ga('create', 'token', 'auto', {"allowLinker":true});
ga('require', 'linker');
ga('linker:autoLink', 'arg1', {arg2: val2});

Everything is compatible with the existing code

@piotrekbator
Copy link

👍

if (config.extraCreateParams) {
createString += ", " + JSON.stringify(config.extraCreateParams);
}
createString += ");";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably some potentially reusable code here. For example:

function makeFunctionDefinition(funcName, funcArgs) {
  return '' + funcName + '(' + funcArgs.map(function(x) {return "'" + x + "'";}).join(', ') + ');';
}
makeFunctionDefinition('GA', ['create', 'a', 'b']); //   "GA('create', 'a', 'b');"

@lucasgray
Copy link

Would love to use this lib but need the linker statement. +1

@Rekhajikki
Copy link

Hi, How do I set domain name for GA.Kindly can one help me .
_gaq.push(['_setDomainName', 'example.com']);

Thanks,
Rekha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants