{"id":29817083,"url":"https://github.com/cybercog/yii2-google-analytics","last_synced_at":"2025-07-28T20:12:12.325Z","repository":{"id":26343312,"uuid":"29792135","full_name":"cybercog/yii2-google-analytics","owner":"cybercog","description":"Google Analytics Universal tracking widget.","archived":false,"fork":false,"pushed_at":"2020-01-28T19:37:33.000Z","size":24,"stargazers_count":15,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-22T12:45:31.812Z","etag":null,"topics":["cog","cybercog","google-analytics","widget","yii2"],"latest_commit_sha":null,"homepage":"http://cybercog.ru","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ant-design/ant-design","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cybercog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-24T21:23:18.000Z","updated_at":"2024-01-28T20:51:09.000Z","dependencies_parsed_at":"2022-08-21T09:20:42.068Z","dependency_job_id":null,"html_url":"https://github.com/cybercog/yii2-google-analytics","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/cybercog/yii2-google-analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybercog%2Fyii2-google-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybercog%2Fyii2-google-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybercog%2Fyii2-google-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybercog%2Fyii2-google-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cybercog","download_url":"https://codeload.github.com/cybercog/yii2-google-analytics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybercog%2Fyii2-google-analytics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267578003,"owners_count":24110351,"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-07-28T02:00:09.689Z","response_time":68,"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":["cog","cybercog","google-analytics","widget","yii2"],"created_at":"2025-07-28T20:12:11.625Z","updated_at":"2025-07-28T20:12:12.311Z","avatar_url":"https://github.com/cybercog.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yii2 Google Analytics Tracking\n\n[![Gitter chat at https://gitter.im/cybercog/yii2-google-analytics](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cybercog/yii2-google-analytics?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Latest Stable Version](https://poser.pugx.org/cybercog/yii2-google-analytics/version)](https://packagist.org/packages/cybercog/yii2-google-analytics)\n[![License](https://poser.pugx.org/cybercog/yii2-google-analytics/license)](https://github.com/cybercog/yii2-google-analytics/blob/master/LICENSE)\n\nThis extension provides easy way to add Universal Analytics tracking in your Yii2 application.\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nRun in console\n\n```bash\nphp composer.phar require cybercog/yii2-google-analytics\n```\n\n## Usage\n\nIn your `/views/layouts/main.php` add\n \n```php\nuse cybercog\\yii\\googleanalytics\\widgets\\GATracking;\n```\n\nThen before `\u003c/head\u003e` add following code\n\n```php\n\u003c?= GATracking::widget([\n    'trackingId' =\u003e 'UA-XXXXXXXX-X',\n]) ?\u003e\n```\n\n## Advanced usage\n\n### Omit script tag\n\nBy default this script generated output:\n\n```html\n\u003cscript\u003e\n(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n\t(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\tm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\nga('create', 'UA-XXXXXXXX-X', \"auto\");\nga('send', 'pageview');\nga('set', 'anonymizeIp', true);\n\u003c/script\u003e\n```\n\nBut sometimes we need the output without `script` tag to combined with `registerJs` or `registerJsFile` as `renderPartial` to add dependency or positioning configuration, you can use *omitScriptTag* **true** to disable `script` tag, example:\n\n```php\n\u003c?= $this-\u003eregisterJs(\n    GATracking::widget([\n        'trackingId' =\u003e 'UA-XXXXXXXX-X',\n        'omitScriptTag' =\u003e true,\n    ]), \\yii\\web\\View::POS_END\n); ?\u003e\n```\n\n### Example of advanced usage\n\nYou can configure tracking script for your needs:\n\n```php\n\u003c?= GATracking::widget([\n    'trackingId' =\u003e 'UA-XXXXXXXX-X',\n    'trackingConfig' =\u003e [\n        'name' =\u003e 'myTracker',\n        'allowAnchor' =\u003e false,\n    ],\n    'omitScriptTag' =\u003e false,\n    'debug' =\u003e true,\n    'debugTrace' =\u003e true,\n    'anonymizeIp' =\u003e true,\n    'plugins' =\u003e [\n        'linkid' =\u003e [\n            'cookieName' =\u003e '_ccli',\n            'duration' =\u003e 45,\n            'levels' =\u003e 5,\n        ],\n    ],\n]) ?\u003e\n```\n\n## Available fields (parameters)\n\n| Field Name | Value Type | Default Value |\n| :--------- | :--------- | :------------ |\n| anonymizeIp | boolean | true |\n| debug | boolean | false |\n| debugTrace | boolean | false |\n\n### [Official field reference](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference)\n\n## Available plugins\n\n### linkid (Enhanced Link Attribution)\n\n| Option Name | Default Value | Description |\n| :---------- | :------------ | :---------- |\n| cookieName  | _gali         | Cookie name |\n| duration    | 30            | Cookie duration (seconds) |\n| levels      | 3             | Max DOM levels from link to look for element ID |\n\n### [Creating your own plugins](https://developers.google.com/analytics/devguides/collection/analyticsjs/plugins)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybercog%2Fyii2-google-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcybercog%2Fyii2-google-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybercog%2Fyii2-google-analytics/lists"}