{"id":19555402,"url":"https://github.com/anki/ga-task-manager","last_synced_at":"2025-08-16T05:33:03.920Z","repository":{"id":75474908,"uuid":"125266008","full_name":"anki/ga-task-manager","owner":"anki","description":"Google Analytics plugin which expands analytics.js Tasks, allowing the user to specify multiple functions to be run for each GA Task. Also provides utility functions to add common tasks.","archived":false,"fork":false,"pushed_at":"2018-09-27T22:44:40.000Z","size":90,"stargazers_count":1,"open_issues_count":0,"forks_count":5,"subscribers_count":52,"default_branch":"feature/WEB-1471-ga-visitor-data","last_synced_at":"2025-04-26T22:34:16.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anki.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-14T19:51:42.000Z","updated_at":"2020-01-03T17:26:54.000Z","dependencies_parsed_at":"2023-06-06T14:45:07.641Z","dependency_job_id":null,"html_url":"https://github.com/anki/ga-task-manager","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/anki/ga-task-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki%2Fga-task-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki%2Fga-task-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki%2Fga-task-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki%2Fga-task-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki","download_url":"https://codeload.github.com/anki/ga-task-manager/tar.gz/refs/heads/feature/WEB-1471-ga-visitor-data","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki%2Fga-task-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270670932,"owners_count":24625653,"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-16T02:00:11.002Z","response_time":91,"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":[],"created_at":"2024-11-11T04:33:50.379Z","updated_at":"2025-08-16T05:33:03.909Z","avatar_url":"https://github.com/anki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Analytics Task Manager\n\nThis guide explains what the `gaTaskManager` plugin is and how to integrate it into your `analytics.js` tracking implementation.\n\n## Overview\n\nGoogle Analytics [Tasks](https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks) is \"an advanced feature used to customize how analytics.js validates, constructs, and sends measurement protocol requests\". `gaTaskManager` is a Google Analytics plugin which expands analytics.js Tasks, allowing the user to specify multiple functions to be run for each GA Task. Also provides utility functions to add common functions to tasks, such as setting Custom Dimensions. If you want to be able to run multiple functions for one or more Tasks included in the measurement protocol's request lifecycle, this is the plugin for you.\n\n## Usage\n\nTo enable the `gaTaskManager` plugin, run the [`require`](https://developers.google.com/analytics/devguides/collection/analyticsjs/using-plugins) command, specify the plugin name `'gaTaskManager'`:\n\n```js\nga('require', 'gaTaskManager');\n```\n\nWhen you require the `gaTaskManager` plugin, its constructor overrides the GA tracker's Tasks' function with its own, and sets the original Task function as the first function to be run for that respective Task. From an output perspective, nothing changes by requiring the plugin, it simply bootstraps the tracker so that you're able to use the methods listed below.\n\n## Methods\n\nThe following table lists all methods for the `gaTaskManager` plugin:\n\n\u003ctable\u003e\n  \u003ctr valign=\"top\"\u003e\n    \u003cth align=\"left\"\u003eName\u003c/th\u003e\n    \u003cth align=\"left\"\u003eDescription\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr valign=\"top\"\u003e\n    \u003ctd\u003e\u003ccode\u003eaddFunctionToTask\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003eAdds a function to be executed at the specified GA Task. Can be used to add to any Task listed at https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr valign=\"top\"\u003e\n    \u003ctd\u003e\u003ccode\u003esetCustomDimension\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003eAdds a function which sets a GA Custom Dimension at the specified GA Task execution time. Defaults to execution on the \u003ccode\u003ecustomTask\u003c/code\u003e Task\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr valign=\"top\"\u003e\n    \u003ctd\u003e\u003ccode\u003eremove\u003c/code\u003e\u003c/td\u003e\n    \u003ctd\u003eRemoves the \u003ccode\u003egaTaskManager\u003c/code\u003e plugin from the specified tracker, restoring all original functions set to each Task prior to the plugin being required.\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nFor details on how `analytics.js` plugin methods work and how to invoke them, see [calling plugin methods](https://developers.google.com/analytics/devguides/collection/analyticsjs/using-plugins#calling_plugin_methods) in the `analytics.js` documentation.\n\n## Examples\n\n### Setting a Custom Dimension at every hit:\n\nThis example sets a Custom Dimension `dimension2` at every Hit:\n\n```js\n  var index = 1;\n  ga('gaTaskManager:setCustomDimension', index, 'foo');\n\n```\n\n### Setting Custom Dimension value just-in-time:\n\nThis example delegates the generation of the value for the Custom Dimension to a function that returns the current timestamp at every Hit:\n\n```js\n  var index = 2;\n  ga('gaTaskManager:setCustomDimension', index, function(){\n    return Date.now() / 1000 | 0;\n  });\n\n```\n\n### Executing an arbitrary function on a Task\n\nThis example adds an arbitrary function to be executed after sending the normal request to\nrequest to www.google-analytics.com/collect.\n\n```js\nga('gaTaskManager:addFunctionToTask', 'sendHitTask', 'sendHitToMyServer', function(model) {\n  // Send a copy of the request to a local server\n  var xhr = new XMLHttpRequest();\n  xhr.open('POST', '/localhits', true);\n  xhr.send(model.get('hitPayload'));\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki%2Fga-task-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki%2Fga-task-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki%2Fga-task-manager/lists"}