HappyPorch / uSplit

A/B Testing plugin for Umbraco
The Unlicense
11 stars 7 forks source link

Added support for multiple Google Analytics accounts #18

Closed hakon-knowit closed 6 years ago

hakon-knowit commented 7 years ago

This is a quite big pull request, so we don't expect this to be accepted right away. We are mainly looking for feedback right now.


Support for multiple GA accounts

This pull request adds support for multiple Analytic Accounts/Projects. These changes are backwards compatible with existing configurations and should "just work" in most cases.

Breaking changes: There are some changes to method signatures and APIs.

Motivation: Our company wanted separate projects for each language tree on our site.

Summary of changes

  1. Added support for multiple sets of configuration options
  2. uSplit:ProfileID is used to identify each account config
  3. Commands and backoffice API now take a profileId parameter

Configuration

These changes are backwards compatible with existing configuration files.

uSplit will look for configuration options of the form: uSplit:[descriptive name]:[option] and uSplit:[option]

Example:

<!-- Norway -->
<add key="uSplit:Norway:googleClientId" value="xxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com" />
<add key="uSplit:Norway:googleClientSecret" value="xxxxxxxxxxxxxxxxx" />
<add key="uSplit:Norway:accountId" value="xxxxxxxx" />
<add key="uSplit:Norway:webPropertyId" value="UA-xxxxxxx-1" />
<add key="uSplit:Norway:profileId" value="xxxxxxx" />

<!-- Finland -->
<add key="uSplit:Finland:googleClientId" value="xxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com" />
<add key="uSplit:Finland:googleClientSecret" value="xxxxxxxxxxxxxxxxx" />
<add key="uSplit:Finland:accountId" value="xxxxxxxx" />
<add key="uSplit:Finland:webPropertyId" value="UA-xxxxxxx-1" />
<add key="uSplit:Finland:profileId" value="xxxxxxx" />

<!-- Old options will continue to work -->
<add key="uSplit:googleClientId" value="xxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com" />
<add key="uSplit:googleClientSecret" value="xxxxxxxxxxxxxxxxx" />
<add key="uSplit:accountId" value="xxxxxxxx" />
<add key="uSplit:webPropertyId" value="UA-xxxxxxx-1" />
<add key="uSplit:profileId" value="xxxxxxx" />

Screenshot image

ondrejpialek commented 7 years ago

Hi @hakon-knowit,

Thank you very much for your contribution, it looks amazing.

I am leaving a comment here to acknowledge this PR and manage your expectations a little bit. I had a surgery done last week and it might take me a week or two before I fully catch up with work and have time to review this PR in detail.

Thanks again and I will be in touch as quickly as I can. Ondrej.

hakon-knowit commented 7 years ago

Thanks for your reply, @ondrejpialek We're not in a rush, so take the time you need :)

ondrejpialek commented 6 years ago

Hello @hakon-knowit,

thank you very much for this great contribution. I am really sorry that it took me so long to get to it - we took on a big project that took all my attention and only now that I am on holiday I have time to look at this in detail.

I have tested your code and it works well so I am merging it in. Over the next few days I will improve the UI to make the configuration a bit easier and provide enough feedback about what is going on at certain stages and then will do a release close to Christmas I would imagine.

Thanks again for this awesome PR and for your time spent on uSplit. I will include your name on the repo readme as a thanks and I have already given you credit at Umbraco Poland Festival in September. Here's a video in case you missed it.

Cheers, Ondrej.