{"id":15405541,"url":"https://github.com/koic/gtm_rails","last_synced_at":"2025-10-08T17:14:34.850Z","repository":{"id":56875469,"uuid":"80010786","full_name":"koic/gtm_rails","owner":"koic","description":"Simply embed Google Tag Manager container snippet into Rails application","archived":false,"fork":false,"pushed_at":"2019-01-25T09:20:25.000Z","size":41,"stargazers_count":17,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T05:51:16.970Z","etag":null,"topics":["google-tag-manager","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-25T12:05:00.000Z","updated_at":"2024-08-06T05:26:56.000Z","dependencies_parsed_at":"2022-08-20T11:30:46.023Z","dependency_job_id":null,"html_url":"https://github.com/koic/gtm_rails","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koic%2Fgtm_rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koic%2Fgtm_rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koic%2Fgtm_rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koic%2Fgtm_rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koic","download_url":"https://codeload.github.com/koic/gtm_rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249299666,"owners_count":21246874,"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":["google-tag-manager","rails"],"created_at":"2024-10-01T16:16:59.399Z","updated_at":"2025-10-08T17:14:29.800Z","avatar_url":"https://github.com/koic.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gtm_rails [![Build Status](https://travis-ci.org/koic/gtm_rails.svg)](https://travis-ci.org/koic/gtm_rails) [![Gem Version](https://badge.fury.io/rb/gtm_rails.svg)](http://badge.fury.io/rb/gtm_rails) [![git.legal](https://git.legal/projects/3929/badge.svg \"Number of libraries approved\")](https://git.legal/projects/3929)\n\nSimply embed Google Tag Manager container snippet into Rails application.\n\n## Installation\n\nAdd these lines to your application's Gemfile:\n\n```\ngem 'gtm_rails'\n```\n\nAnd then execute:\n\n```\n$ bundle install\n```\n\n## Configuration\n\nCreate `config/google_tag_manager.yml` in your Rails application.\n\n```yaml\nstaging:\n  foo: GTM-YourGtmId1\n  bar: GTM-YourGtmId2\n  baz: GTM-YourGtmId3\nproduction:\n  foo: GTM-YourGtmId4\n  bar: GTM-YourGtmId5\n  baz: GTM-YourGtmId6\n```\n\nThe above is a sample. `foo`, `bar`, `baz` are arbitrary label names, and replacing GTM-XXXX with your container ID.\n\nIn view, use two helper methods.\n\n1. `google_tag_manager_script_tag(label_name)`\n2. `google_tag_manager_noscript_tag(label_name)`\n\nThese method arguments are a label name specified in `config/google_tag_manager.yml`.\n\nFirst, following method as close to the opening `\u003chead\u003e` tag as possible on every page of your website.\n\n```erb\n\u003c%= google_tag_manager_script_tag(:foo) %\u003e\n```\n\nGoogle Tag Manager container snippet will be expanded based on `Rails.env` and label name. If there is no match, a blank string is returned.\n\n```html\n\u003c!-- Google Tag Manager --\u003e\n\u003cscript\u003e(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'\u0026l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer','GTM-YourGtmId1');\u003c/script\u003e\n\u003c!-- End Google Tag Manager --\u003e\n```\n\nSecond, following method immediately after the opening `\u003cbody\u003e` tag on every page of your website.\n\n```erb\n\u003c%= google_tag_manager_noscript_tag(:foo) %\u003e\n```\n\nGoogle Tag Manager container snippet will be expanded based on `Rails.env` and label name. If there is no match, a blank string is returned.\n\n```html\n\u003c!-- Google Tag Manager (noscript) --\u003e\n\u003cnoscript\u003e\u003ciframe src=\"https://www.googletagmanager.com/ns.html?id=GTM-YourGtmId1\"\nheight=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"\u003e\u003c/iframe\u003e\u003c/noscript\u003e\n\u003c!-- End Google Tag Manager (noscript) --\u003e\n```\n\nFor more detailed GTM please click here to [read more](https://developers.google.com/tag-manager/quickstart).\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## License\n\ngtm_rails is released under the [MIT License](http://www.opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoic%2Fgtm_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoic%2Fgtm_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoic%2Fgtm_rails/lists"}