{"id":13545687,"url":"https://github.com/Happyr/GoogleAnalyticsBundle","last_synced_at":"2025-04-02T15:31:48.494Z","repository":{"id":435426,"uuid":"11168686","full_name":"Happyr/GoogleAnalyticsBundle","owner":"Happyr","description":"The Google Analytics Bundle lets you send data (like event tracking) to Google.","archived":false,"fork":false,"pushed_at":"2023-11-08T10:59:48.000Z","size":105,"stargazers_count":49,"open_issues_count":7,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-03T11:04:08.894Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","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/Happyr.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-07-04T06:35:54.000Z","updated_at":"2023-12-31T20:53:03.000Z","dependencies_parsed_at":"2024-01-16T17:17:00.628Z","dependency_job_id":null,"html_url":"https://github.com/Happyr/GoogleAnalyticsBundle","commit_stats":{"total_commits":97,"total_committers":7,"mean_commits":"13.857142857142858","dds":0.08247422680412375,"last_synced_commit":"6d071349b9906d0089884b2d750341a7d3deb3f0"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Happyr%2FGoogleAnalyticsBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Happyr%2FGoogleAnalyticsBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Happyr%2FGoogleAnalyticsBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Happyr%2FGoogleAnalyticsBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Happyr","download_url":"https://codeload.github.com/Happyr/GoogleAnalyticsBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246841858,"owners_count":20842659,"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-08-01T11:01:09.733Z","updated_at":"2025-04-02T15:31:43.479Z","avatar_url":"https://github.com/Happyr.png","language":"PHP","readme":"Google Analytics Bundle\n=======================\n\n[![Latest Version](https://img.shields.io/github/release/Happyr/GoogleAnalyticsBundle.svg?style=flat-square)](https://github.com/Happyr/GoogleAnalyticsBundle/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://img.shields.io/github/checks-status/Happyr/GoogleAnalyticsBundle/master?label=build\u0026style=flat-square)](https://github.com/Happyr/GoogleAnalyticsBundle/actions?query=branch%3Amaster)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Happyr/GoogleAnalyticsBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/Happyr/GoogleAnalyticsBundle)\n[![Quality Score](https://img.shields.io/scrutinizer/g/Happyr/GoogleAnalyticsBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/Happyr/GoogleAnalyticsBundle)\n[![Total Downloads](https://img.shields.io/packagist/dt/happyr/google-analytics-bundle.svg?style=flat-square)](https://packagist.org/packages/happyr/google-analytics-bundle)\n\nGoogleAnalyticsBundle is a Symfony2 bundle that helps you to push data to Google Analytics.\nIt could be data like pageview, events etc. It is a bundle implementation of\nthe [Measurement Protocol][devguide]\n\nThis is not a library to pull data from Google analytics. That feature is deprecated from the `classic-analytics` branch.\nThe master branch and version 3 and above will be supporting Google analytics universal.\n\n## Special feature\n\nThis bundle has a special feature. Say that you want to post data to Analytics. You want to post an event every time someone downloads a file. You may do that from the server like any other library. When looking at the reports you will find that you are missing the information about the actual user for the download event. You can not use a segment to find out which referal the user came from. \n\nThis bundle helps you with just that. Before we submit any data we look at the `_ga` cookie to find the user's clientId. So now you may use segments and advanced queries to analytics and you will get the expected result. \n\n## Usage\n\nRead the documentation of the [protocol][devguide].\n\n``` php\n\n//in some container aware class\n$tracker = $this-\u003eget(Tracker::class);\n$data=array(\n    'dh'=\u003e'mydemo.com',\n    'dp'=\u003e'/home',\n    'dt'=\u003e'homepage',\n);\n$tracker-\u003esend($data, 'pageview');\n\n```\n\n## Installation\n\nInstall with composer.\n\n\n``` bash\ncomposer require happyr/google-analytics-bundle\n```\n\n### Step 2: Register the bundle\n\nRegister the bundle in the AppKernel.php\n\n```php\n\u003c?php\n\n// in AppKernel::registerBundles()\n$bundles = array(\n    // ...\n    new Happyr\\GoogleAnalyticsBundle\\HappyrGoogleAnalyticsBundle(),\n    // ...\n);\n```\n\n### Step 3: Configure the bundle\n\n``` yaml\n# app/config/config.yml\n\nhappyr_google_analytics:\n    // ...\n    tracking_id: UA-XXXX-Y\n```\n\n### Step 4: Provide a HTTP client and message factory service. \n\nYou need to provide two services to that know how to create and send message factories. The services must implement\n`Http\\Message\\RequestFactory` and `Http\\Client\\HttpClient`. If you use [HTTPlugBundle](https://github.com/php-http/HttplugBundle)\n this will be taken care of automatically. You will aslo get some nice logging features. \n\n``` yaml\n# app/config/config.yml\n\nhappyr_google_analytics:\n    // ...\n    http_client: 'httplug.client'\n    http_message_factory: 'httplug.message_factory\n```\n\n## Fetching data\n\nIf you want to fetch data from Google Analytics you must install and configure [GoogleSiteAuthenticatorBundle][siteAuth]. Read its documentaion and then configure the analytics bundle with a `client service` and a `view id`. The `view id` is found in the admin section on Google analytics. Go to Admin \u003e Account \u003e Property \u003e View \u003e View settings. \n\n``` yaml\n# app/config/config.yml\n\nhappyr_google_analytics:\n    // ...\n    tracking_id: UA-XXXX-Y\n    fetching:\n        client_service: 'google.client.tobias_gmail'\n        view_id: 0123456789\n        cache_service: 'cache.provider.my_memcached' # optinally a PSR6 cache service\n        cache_lifetime: 3600 # default\n```\n\nYou may then run the following code to get the page views for /example-page.\n\n``` php\n$fetcher = $this-\u003eget(AnalyticsDataFetcher::class);\n$pv = $fetcher-\u003egetPageViews('/example-page');\n```\n\n\n[devguide]: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide\n[siteAuth]: https://github.com/Happyr/GoogleSiteAuthenticatorBundle\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHappyr%2FGoogleAnalyticsBundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHappyr%2FGoogleAnalyticsBundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHappyr%2FGoogleAnalyticsBundle/lists"}