{"id":40052356,"url":"https://github.com/rollercodester/sparga","last_synced_at":"2026-01-19T06:30:30.356Z","repository":{"id":57366890,"uuid":"104282821","full_name":"rollercodester/sparga","owner":"rollercodester","description":"A convenience library for SPAs that use Google Analytics.","archived":false,"fork":false,"pushed_at":"2018-01-12T06:38:08.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-06T09:46:22.685Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rollercodester.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-09-21T00:42:56.000Z","updated_at":"2017-09-21T00:46:45.000Z","dependencies_parsed_at":"2022-08-23T20:10:56.269Z","dependency_job_id":null,"html_url":"https://github.com/rollercodester/sparga","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rollercodester/sparga","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollercodester%2Fsparga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollercodester%2Fsparga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollercodester%2Fsparga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollercodester%2Fsparga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rollercodester","download_url":"https://codeload.github.com/rollercodester/sparga/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollercodester%2Fsparga/sbom","scorecard":{"id":783414,"data":{"date":"2025-08-11","repo":{"name":"github.com/rollercodester/sparga","commit":"b621dd3f9f39754842374e7024d964f05228188f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"63 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-hr2v-3952-633q","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-7px7-7xjx-hxm8","Warn: Project is vulnerable to: GHSA-x5pg-88wf-qq4p","Warn: Project is vulnerable to: GHSA-p9wx-2529-fp83","Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj","Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3","Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7","Warn: Project is vulnerable to: GHSA-mxhp-79qh-mcx6","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-g7q5-pjjr-gqvp","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T05:27:20.473Z","repository_id":57366890,"created_at":"2025-08-23T05:27:20.473Z","updated_at":"2025-08-23T05:27:20.473Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28562404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-19T06:30:27.003Z","updated_at":"2026-01-19T06:30:30.349Z","avatar_url":"https://github.com/rollercodester.png","language":"JavaScript","readme":"\u003cbr /\u003e\n\n[![npm](http://img.shields.io/npm/v/sparga.svg)](https://www.npmjs.org/package/sparga)\n[![travis](https://travis-ci.org/rollercodester/sparga.svg?branch=master)](https://travis-ci.org/rollercodester/sparga)\n[![Dependency Status](https://david-dm.org/rollercodester/sparga.svg)](https://david-dm.org/rollercodester/sparga)\n\n![sparga](https://user-images.githubusercontent.com/1450389/30691215-e68697de-9e7b-11e7-8d7c-a7a6e7c4d34c.jpg)\n\n**S**ingle-**P**age **A**pplication **R**elay for **G**oogle **A**nalytics\n\n### *Are you a Spargan?*\n\n#### You can be if you need to relay hits from your single-page application to Google Analytics.\n\n## Index\n\n* [Installation](#installation)\n* [Examples](#examples)\n   * [Quick Start](#example1)\n   * [Automatic click-streaming](#example2)\n   * [Custom dimensions](#example3)\n   * [Custom metrics](#example4)\n   * [Multiple Tracking Ids (i.e. multiple named trackers)](#example5)\n   * [Native GA Settings (e.g. custom tracker)](#example6)\n* [Default GA Settings](#defaultGaSettings)\n* [Other Helper Functions](#otherHelperFunctions)\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n```javascript\nnpm install --save sparga\n```\n\n\u003ca name=\"examples\"\u003e\u003c/a\u003e\n## Examples\n\n\u003ca name=\"example1\"\u003e\u003c/a\u003e\n### Quick Start\n\n```javascript\n// for ES6 clients\nimport Sparga from 'sparga'\n// for non-ES6 clients\nconst Sparga = require('sparga').default\n\nconst sparga = new Sparga()\n\nsparga.init('UA-123456-7')\n\n//\n// Now all page views in your SPA will\n// automatically be tracked in GA.\n//\n// Additionally, all unhandled JavaScript\n// exceptions will also be tracked.\n//\n// NOTE: Automatic tracking of page views\n// and JavaScript exceptions can be turned\n// off by setting respective flags to false\n// on the options object. See the API docs\n// for specifics.\n//\n```\n\n\u003ca name=\"example2\"\u003e\u003c/a\u003e\n### Automatic click-stream handling\n\n```javascript\n\nconst sparga = new Sparga()\n\nsparga.init({\n   gaSettings: 'UA-123456-7',\n   autoCaptureClickEvents: true\n})\n\n//\n// Now all mouse clicks in your SPA will\n// automatically be tracked in GA.\n//\n```\n\n\u003ca name=\"example3\"\u003e\u003c/a\u003e\n### Setting custom dimensions using developer friendly logical names\n\nFor more info, refer to the [GA Field Reference](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs)\n\n```javascript\n\nconst sparga = new Sparga()\n\nsparga.init({\n   gaSettings: 'UA-123456-7',\n   //\n   // your dimension map will likely be governed\n   // by a central team as GA only allows a limited\n   // number of custom dimensions, depending on your\n   // account type...as such, this map is usually\n   // defined once and used many times for an organization\n   //\n   dimensionMap: {\n      variantTestName: 'dimension1',\n      variantTestSampling: 'dimension9',\n      userRole: 'dimension17'\n   }\n})\n\nsparga.setDimension('variantTestName', 'Variant Testing for Our Exciting New Feature')\nsparga.setDimension('variantTestSampling', 'Customers in US having more than 100 users.')\nsparga.setDimension('userRole', 'non-admin')\n```\n\n\u003ca name=\"example4\"\u003e\u003c/a\u003e\n### Setting custom metrics using developer friendly logical names\n\nFor more info, refer to the [GA Field Reference](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs)\n\n```javascript\n\nconst sparga = new Sparga()\n\nsparga.init({\n   gaSettings: 'UA-123456-7',\n   //\n   // your metric map will likely be governed\n   // by a central team as GA only allows a limited\n   // number of custom metrics, depending on your\n   // account type...as such, this map is usually\n   // defined once and used many times for an organization\n   //\n   metricMap: {\n      isNewUser: 'metric6',\n      isUserAdmin: 'metric8',\n      isViewSetAsPersistent: 'metric14'\n   }\n})\n\nsparga.setMetric('isNewUser', 1)\nsparga.setMetric('isUserAdmin', 0)\nsparga.setMetric('isViewSetAsPersistent', 1)\n```\n\n\u003ca name=\"example5\"\u003e\u003c/a\u003e\n### Using multiple tracking IDs (i.e. multiple named trackers)\n\nSometimes a site/page needs to report to multiple tracking IDs, which is only possible if named trackers are used.\n\n```javascript\n\nconst sparga = new Sparga()\n\n// NOTE: If a trackerMap is provided, then the\n// gaSetting.trackingId will be ignored.\n\nsparga.init({\n   gaSettings: {\n      trackingId: 'THIS WILL NOW BE IGNORED!'\n   },\n   trackerMap: {\n      myTracker1: 'UA-123456-7',\n      myTracker2: 'UA-123456-8',\n      myTracker3: 'UA-123456-9'\n   }\n})\n\n//\n// Now all of the above tracking IDs will be sent pageview\n// and exception events.\n//\n// Additionally, all of the Sparga helper methods will also\n// use the above tracking IDs--or a subset of them, if specified\n//\n\n// send a custom event to ALL trackers (i.e. all tracking IDs)\nsparga.sendEvent(\n   'MyCategory-1', 'MyAction-1', 'MyLabel-1', 'MyValue-1'\n)\n\n// send a custom event to only TWO of the three trackers\nsparga.sendEvent(\n   'MyCategory-2', 'MyAction-2', 'MyLabel-2', 'MyValue-2',\n   [ 'myTracker1', 'myTracker3']\n)\n\n```\n\n\u003ca name=\"example6\"\u003e\u003c/a\u003e\n### Using native GA settings\n\nAll native options for creating a GA tracking session are exposed via the gaSettings property on Sparga's intitialization object. The following example shows how to create a custom tracker by initializing with a gaSettings object.\n\n```javascript\n\nconst sparga = new Sparga()\n\nsparga.init({\n   gaSettings: {\n      trackingId: 'UA-123456-7',\n      userId: 'user123',\n      sessionControl: 'start',\n      cookieExpires: 86400\n   }\n})\n\n```\n\n\u003ca name=\"defaultGaSettings\"\u003e\u003c/a\u003e\n## Default GA Settings\n\nSparga sets the following GA settings by default, which are different than the defaults that GA applies. As with all settings, these are overridable by passing in the respective key-value pairs on the gaSettings property of the options object.\n\n* allowAnchor: false\n* alwaysSendReferrer: true\n* forceSSL: true\n* cookieDomain: 'auto'\n* siteSpeedSampleRate: 100\n* storeGac: false\n\n\n\u003ca name=\"otherHelperFunctions\"\u003e\u003c/a\u003e\n## Other Helper Functions\n\n* sendEvent\n* sendPageView\n* sendException\n* sendSocial\n* sendTiming\n\nRefer to the [API.doc](https://github.com/rollercodester/sparga/blob/master/API.md) for more details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollercodester%2Fsparga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frollercodester%2Fsparga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollercodester%2Fsparga/lists"}