{"id":30359023,"url":"https://github.com/renatocassino/googleanalyticsab","last_synced_at":"2026-03-11T19:31:28.358Z","repository":{"id":57252071,"uuid":"116287068","full_name":"renatocassino/googleAnalyticsAB","owner":"renatocassino","description":"Js lib to create A/B tests using events in Google Analytics","archived":false,"fork":false,"pushed_at":"2018-04-06T18:15:03.000Z","size":214,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-08T23:25:43.208Z","etag":null,"topics":["ab","analytics","ga","google","test"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/renatocassino.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-04T17:14:03.000Z","updated_at":"2019-06-26T17:55:10.000Z","dependencies_parsed_at":"2022-09-06T00:41:59.694Z","dependency_job_id":null,"html_url":"https://github.com/renatocassino/googleAnalyticsAB","commit_stats":null,"previous_names":["tacnoman/googleanalyticsab"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/renatocassino/googleAnalyticsAB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renatocassino%2FgoogleAnalyticsAB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renatocassino%2FgoogleAnalyticsAB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renatocassino%2FgoogleAnalyticsAB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renatocassino%2FgoogleAnalyticsAB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renatocassino","download_url":"https://codeload.github.com/renatocassino/googleAnalyticsAB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renatocassino%2FgoogleAnalyticsAB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271143566,"owners_count":24706392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ab","analytics","ga","google","test"],"created_at":"2025-08-19T11:19:16.281Z","updated_at":"2025-12-12T05:49:24.842Z","avatar_url":"https://github.com/renatocassino.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Analytics AB\n\n[![Version](http://img.shields.io/npm/v/google-analytics-ab.svg)](https://www.npmjs.org/package/google-analytics-ab) [![Build Status](https://travis-ci.org/tacnoman/googleAnalyticsAB.svg?branch=master)](https://travis-ci.org/tacnoman/googleAnalyticsAB) [![codecov](https://codecov.io/gh/tacnoman/googleAnalyticsAB/branch/master/graph/badge.svg)](https://codecov.io/gh/tacnoman/googleAnalyticsAB) [![Code Climate](https://codeclimate.com/github/tacnoman/googleAnalyticsAB/badges/gpa.svg)](https://codeclimate.com/github/tacnoman/googleAnalyticsAB) [![HitCount](http://hits.dwyl.io/tacnoman/googleAnalyticsAB.svg)](http://hits.dwyl.io/tacnoman/googleAnalyticsAB)\n\n\nLib tool in javascript to create A/B tests using Google Analytics events in easy way. With a simple configuration you can edit your page and get metrics.\n\n## Getting started\n\n### NPM\nTo install using npm you must run.\n\n```bash\n$ npm i --save google-analytics-ab\n```\n\nAnd use require to get the lib.\n\n```js\nvar googleAnalyticsAB = require('googleAnalyticsAB');\n\n// Or with ecma6\n\nimport googleAnalyticsAB from 'googleAnalyticsAB'\n```\n\n### Bower\nTo install using Bower you must run.\n\n```bash\n$ bower install google-analytics-ab\n```\n\nYou can get in folder dist the compressed file (`/dist/google-analytics-ab.min.js`).\n\n## Dependencies\n\n- Google Analytics script (obvious?)\n\n## Create your own first test\n\nYou must have GA script in your page.\n\nTo make a simple test, you can call:\n```html\n.....\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/google-analytics-ab@latest/dist/google-analytics-ab.min.js\"\u003e\u003c/script\u003e\n.....\n```\n\n```js\n\n  // Example of AB change button color. Green or Red.\n  googleAnalyticsAB.create({\n    name: 'MY_TEST', // Name of your first test\n    percentage: 80, // Percentage of users to run in this test (Default is 80)\n\n    // Alternatives\n    options: [\n      {\n        name: 'green-button', // Name of your alternative\n        weight: 1, // weight of your alternative (optional, default is 1)\n      },\n      {\n        name: 'red-button',\n        weight: 1,\n      }\n    ],\n\n    // Method called when AB is sorted\n    run: function(option) { // Current option\n      var myButton = document.getElementById('myButton'); // Getting some button\n      myButton.style.background = option.name === 'green-button' ? '#0F0' : '#F00'; // Change color using the label\n\n      // Event onClick in button tested\n      myButton.addEventListener('click', function(ev) {\n        option.convert(); // Option has a method called convert. Use to convert :D\n      });\n    }\n  });\n\n```\n\n## How to see the results\n\nOpen your Google Analytics account and go to:\n\n`Behavior \u003e Events \u003e Overview`\n\nIn Event category, go to `googleAnalyticsAB`.\n\nClick in `Event Action`.\n\n\u003cimg src=\"https://raw.githubusercontent.com/tacnoman/googleAnalyticsAb/master/images/top-events-analytics-01.jpg\" alt=\"logo\" title=\"Event action\"\u003e\n\nNow, you will see all A/B tests running.\nClick in your current A/B test.\n\nNow, you will see your options, check all and click in `Plot rows`.\n\n\u003cimg src=\"https://raw.githubusercontent.com/tacnoman/googleAnalyticsAb/master/images/top-events-analytics-02.jpg\" alt=\"logo\" title=\"Analytics plot lines\"\u003e\n\nSee your test result :D\n\n\u003cimg src=\"https://raw.githubusercontent.com/tacnoman/googleAnalyticsAb/master/images/top-events-analytics-03.jpg\" alt=\"logo\" title=\"Analytics result\"\u003e\n\n\nPs: If you cannot see the events, you need change the date and add the current day.\n\nBugs? Tacnoman `\u003crenatocassino@gmail.com\u003e`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenatocassino%2Fgoogleanalyticsab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenatocassino%2Fgoogleanalyticsab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenatocassino%2Fgoogleanalyticsab/lists"}