{"id":22965801,"url":"https://github.com/thenextweb/cro","last_synced_at":"2025-08-13T08:32:43.746Z","repository":{"id":36652241,"uuid":"40958539","full_name":"thenextweb/cro","owner":"thenextweb","description":"A/B + Multivariate Testing via Google Tag Manager","archived":false,"fork":false,"pushed_at":"2016-04-27T10:26:32.000Z","size":18,"stargazers_count":142,"open_issues_count":0,"forks_count":28,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-03-26T08:45:01.612Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://thenextweb.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thenextweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-18T07:54:53.000Z","updated_at":"2024-02-14T10:08:58.000Z","dependencies_parsed_at":"2022-09-08T23:00:19.869Z","dependency_job_id":null,"html_url":"https://github.com/thenextweb/cro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenextweb%2Fcro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenextweb%2Fcro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenextweb%2Fcro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenextweb%2Fcro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thenextweb","download_url":"https://codeload.github.com/thenextweb/cro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229749174,"owners_count":18118325,"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","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":[],"created_at":"2024-12-14T20:16:30.343Z","updated_at":"2024-12-14T20:16:30.857Z","avatar_url":"https://github.com/thenextweb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A/B/n Testing with Google Tag Manager\nScripts that support A/B/n + Multivariate Testing (for [The Next Web]\n(http://thenextweb.com)), via [Google Tag Manager](http://tagmanager.google.com).\n\nFeatures\n--------\n* Supports: A/B/n testing and Multivariate testing.\n* Integration with Google Analytics, will send data for event to the dataLayer.\n* Supported via Google Tag Manager but also easily configurable to run natively.\n\n\u003chr /\u003e\n\n## Usage\nBoth scripts work in a similar order and require the use of Google Tag Manager\nto make sure it will work. You can add a new tag there to make sure your\nvariants are working.\n\n* `prefix` - a string that is going to be used to set cookies + check for tests.\n* `randomNumber` - the randon number variable used in Google Tag Manager. Make\nsure you enabled Random Number as a variable in GTM.\n* `variants` - the code for the variants, you can add an unlimited amount of variants.\n\nWe'll check if a user is in a certain variant to make sure that the user doesn't\nget any mixed up experiences. Next to that we also make sure the user is not in\nany other test currently by checking for any cookies that start with: `tnw`.\n\n### Quick start:\nInclude the whole script and at the top of the script change the testing variables:\n\n\t// Variables\n\tvar prefix = 'tnw';\n\tvar randomNumber = {{Random Number}};\n\tvar changes = {\n\t    1: {\n\t        variants: {\n\t            1: {\n\t                execute: function () {\n\n\t                }\n\t            }\n\t        }\n\t    },\n\t    2: {\n\t        variants: {\n\t            1: {\n\t                execute: function () {\n\n\t                }\n\t            },\n\t            2: {\n\t                execute: function () {\n\n\t                }\n\t            }\n\t        }\n\t    }\n\t};\n\n*Note:* You'll never have to add 0, which is the original, it will take care of\nthe original variant itself.\nYou can read more about [how to add a test in Google Tag Manager here](https://github.com/MartijnSch/cro/wiki/How-to-add-a-test-in-Google-Tag-Manager-(GTM)).\n\n#### Google Analytics\nTo measure the variants + experiments in Google Analytics we send the data to\nGoogle Analytics via the dataLayer. In both scripts we send the data via the\n`abTest` event.\nYou'll have to create a custom report in Google Analytics to show you the\nspecific data for your variants.\n\nData in Google Analytics for different variants will show up like:\n\n* `prefix-{testID}-{testVariant}` for A/B testing.\n* `prefix-{testID}-{changeID}-{testVariant}` for multivariate testing (MVT).\n\n#### Cookies\nWe set the cookies for the length of the test that is added in the variables at\nthe beginning of a test. The names and values of the cookies look like:\n\n* Name: `prefix-{testID}`, with the value: `{testVariant}` for A/B testing.\n* Name: `prefix-{testID}`, with the value: `{changeID}-{testVariant}` for\nmultivariate testing (MVT).\n\n*Note:* We prepend the cookie name: `tnw` but obviously you can change this to\nwhatever you'd like by changing the prefix variable: `prefix`.\n\nHistory\n=======\n#### April 27, 2016 (2016-04-27)\n* Allow for running A/B/n tests.\n* Change the use of the pre-fix.\n* Add support for the dataLayer.\n* Clean \u0026 tidy up a lot of code.\n\n#### November 21, 2015 (2015-11-21)\n* Add a preview URL.\n\n#### September 27, 2015 (2015-09-27)\n* Added a check to see if Google Analytics is initialized.\n\n#### August 18, 2015 (2015-08-18)\n* Initial commit to add more information to the README.\n\n\n# Want to contribute?\nContributions are welcome! There are just a few requested guidelines:\n\n* Please create a feature branch for your changes and squash commits.\n* Don't worry about updating the version, changelog, or minified version.\n* Please respect the original syntax/formatting stuff.\n* If proposing a new feature, it may be a good idea to create an issue first to discuss.\n\nMaintainer history\n------------------\n  * [Martijn Scheijbeler](https://github.com/martijnsch/cro) (Current)\n  * [Simon Vreeman](https://github.com/simonvreeman/a-b-testing-with-google-tag-manager) (Current)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenextweb%2Fcro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenextweb%2Fcro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenextweb%2Fcro/lists"}