{"id":19569032,"url":"https://github.com/d6y/liftmodules-googleanalytics","last_synced_at":"2025-04-27T03:30:37.032Z","repository":{"id":57737377,"uuid":"1252286","full_name":"d6y/liftmodules-googleanalytics","owner":"d6y","description":"A Lift Module to add Google Analytics Tracking code a web site.","archived":false,"fork":false,"pushed_at":"2018-05-09T16:15:32.000Z","size":2174,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T20:24:49.040Z","etag":null,"topics":["googleanalytics","lift","lift-framework","liftmodules","liftweb"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/d6y.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-01-13T21:30:37.000Z","updated_at":"2018-05-09T16:15:33.000Z","dependencies_parsed_at":"2022-08-24T06:21:37.999Z","dependency_job_id":null,"html_url":"https://github.com/d6y/liftmodules-googleanalytics","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d6y%2Fliftmodules-googleanalytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d6y%2Fliftmodules-googleanalytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d6y%2Fliftmodules-googleanalytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d6y%2Fliftmodules-googleanalytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d6y","download_url":"https://codeload.github.com/d6y/liftmodules-googleanalytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251085147,"owners_count":21533821,"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":["googleanalytics","lift","lift-framework","liftmodules","liftweb"],"created_at":"2024-11-11T06:07:21.207Z","updated_at":"2025-04-27T03:30:36.765Z","avatar_url":"https://github.com/d6y.png","language":"Scala","readme":"# Google Analytics Lift Module\n\n[![Build Status](https://travis-ci.org/d6y/liftmodules-googleanalytics.svg?branch=master)](https://travis-ci.org/d6y/liftmodules-googleanalytics)\n\nInserts the [Google Analytics async tracking code](http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html) into a [Lift](http://www.liftweb.net) application.\n\nThat is, if you supply a Google Analytics tracking ID, the head of all pages will have the Google tracking Javascript code automatically added.\n\n\n## Using this module\n\n1. Include the dependency:\n\n        // For Lift 3.2.x (Scala 2.12):\n        \"net.liftmodules\" %% \"google-analytics_3.2\" % \"1.2.0\"\n\n    Note that from 1.2.0 onwards this module switched to using Google Tag Manager (via [#8](https://github.com/d6y/liftmodules-googleanalytics/pull/8)).\n    The versions below use the older `ga.js` approach.\n\n        // For Lift 3.1.x (Scala 2.12):\n        \"net.liftmodules\" %% \"google-analytics_3.1\" % \"1.1.0-SNAPSHOT\"\n\n        // For Lift 3.0.x (Scala 2.12, 2.11):\n        \"net.liftmodules\" %% \"google-analytics_3.0\" % \"1.1\"\n\n        // For Lift 3.0.x (Scala 2.10):\n        \"net.liftmodules\" %% \"google-analytics_3.0\" % \"1.0-SNAPSHOT\"\n\n        // For Lift 2.6.x (Scala 2.11):\n        \"net.liftmodules\" %% \"google-analytics_2.6\" % \"1.1-SNAPSHOT\"\n\n        // For Lift 2.6.x (Scala 2.9 and 2.10):\n        \"net.liftmodules\" %% \"google-analytics_2.6\" % \"1.0\"\n\n        // For Lift 2.5.x (Scala 2.9 and 2.10):\n         \"net.liftmodules\" %% \"google-analytics_2.5\" % \"1.0\"\n\n\n2. In your application's Boot.boot code:\n\n          bootstrap.liftmodules.GoogleAnalytics.init\n\n3. Finally, set your tracking code as the `google.tag.manager.id` in your Props file.  For example, add the following to `src/main/resources/production.default.props`\n\n         google.tag.manager.id=GTM-XXXXXX\n\n    ...obviously replacing `XXXXXX` with the code Google issued you with.  Be sure to start your Lift app with `-Drun.mode=production` flag (or set the value of google.tag.manager.id in your dev props file).\n\n\n## Conditional behaviour\n\nTo selectively control if analytics is enable, provide a `()=\u003eBoolean` function to the `init` method:\n\n    import bootstrap.liftmodules.GoogleAnalytics\n\n    GoogleAnalytics.init { () =\u003e S.cookieValue(\"cookie_consent\") isDefined }\n\nThere's some sugar if you want it:\n\n    import bootstrap.liftmodules.GoogleAnalytics\n    import GoogleAnalytics.dsl._\n\n    GoogleAnalytics.init {\n     only when S.cookieValue(\"ckns_policy\").isDefined\n    }\n\n\n## End user cookie notification\n\nTo assist towards compliance to the EU Privacy and Electronic Communications Regulations (cookie laws) this module includes an end-user notification trigger.  It may not be right for you, and it is your responsibility to review you compliance with any regulation.\n\n    GoogleAnalytics.alertUser ( only when S.cookieValue(\"cookie_consent\").isEmpty ) {\n      JsAlert(\"We set Cookies\")\n    }\n\nThe `alertUser` method expects a test of type `()=\u003eBoolean` and then a `()=\u003eJsCmd`.\n\n\n## Development\n\nWhen working on this module, if you want to see the effect in a Lift project without having to publish the module, you can change your Lift project to remove the dependency on the published module and instread add a local dependency.  E.g.,\n\n    // project/LoalModuleDev.scala\n    import sbt._\n    object LocalModuleDev extends Build {\n      lazy val root = Project(\"\", file(\".\")) dependsOn(google)\n      lazy val google = ProjectRef(uri(\"../liftmodules-googleanalytics\"), \"LiftModule\")\n    }\n\nWhen you build your Lift project, SBT will automatically compile changes in the local Google Analytics module.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd6y%2Fliftmodules-googleanalytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd6y%2Fliftmodules-googleanalytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd6y%2Fliftmodules-googleanalytics/lists"}