{"id":4072,"date":"2021-06-24T07:23:45","date_gmt":"2021-06-23T22:23:45","guid":{"rendered":"https:\/\/ecpplus.net\/weblog\/?p=4072"},"modified":"2021-06-20T19:28:28","modified_gmt":"2021-06-20T10:28:28","slug":"gtag-fallback","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/gtag-fallback\/","title":{"rendered":"Google \u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306e\u30a4\u30d9\u30f3\u30c8\u9001\u4fe1\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306f\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u51e6\u7406\u304c\u5fc5\u8981"},"content":{"rendered":"<a target=\"_blank\" href=\"\" rel=\"noreferrer noopener\">gtag.js \u3092\u4f7f\u7528\u3057\u3066 Google \u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306b\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b<\/a>\n<p><code>gtag.js<\/code> \u3067Google \u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306b\u30a4\u30d9\u30f3\u30c8\u3092\u9001\u4fe1\u3057\u305f\u3042\u3068\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3067\u6b21\u306e\u51e6\u7406\u306b\u9032\u3082\u3046\u3068\u3059\u308b\u5834\u5408\u3001\u5fc5\u305a\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u51e6\u7406\u3092\u4ed8\u3051\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p><code>gtags.js<\/code> \u304c\u6b63\u3057\u304f\u8aad\u307f\u8fbc\u307e\u308c\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u3001\u30a4\u30d9\u30f3\u30c8\u9001\u4fe1\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u304c\u547c\u3070\u308c\u306a\u3044\u305f\u3081\u3060\u3002\u5358\u7d14\u306b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc\u3067\u8aad\u307e\u308c\u306a\u3044\u5834\u5408\u3082\u3042\u308c\u3070\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30aa\u30f3\u306b\u3088\u308a\u30d6\u30ed\u30c3\u30af\u3055\u308c\u3066\u8aad\u307e\u308c\u306a\u3044\u5834\u5408\u3082\u3042\u308b\u3002\u3061\u306a\u307f\u306b\u3001 <a target=\"_blank\" href=\"https:\/\/tools.google.com\/dlpage\/gaoptout\/\" rel=\"noreferrer noopener\"> Google Analytics Opt-out Browser Add-on <\/a> \u3067\u30aa\u30d7\u30c8\u30a2\u30a6\u30c8\u3057\u305f\u5834\u5408\u306f\u3001\u30a4\u30d9\u30f3\u30c8\u304c Google \u306b\u9001\u4fe1\u3055\u308c\u306a\u3044\u3060\u3051\u3067\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306f\u5b9f\u884c\u3055\u308c\u308b\u3002<\/p>\n<p>\u65b9\u6cd5\u306f\u3001<a target=\"_blank\" href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/gtagjs\/sending-data#handle_timeouts\" rel=\"noreferrer noopener\">\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306b\u5bfe\u51e6\u3059\u308b(\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8)<\/a> \u306b\u3042\u308b\u3088\u3046\u306b\u3001\u5358\u7d14\u306b <code>setTimeout<\/code> \u3067\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u304c\u672a\u547c\u3073\u51fa\u3057\u3060\u3063\u305f\u5834\u5408\u306b\u547c\u3076\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308c\u3070OK\u3002<\/p>\n<pre><code class=\"language-js\">\/\/ Gets a reference to the form element, assuming\n\/\/ it contains the ID attribute &quot;signup-form&quot;.\nvar form = document.getElementById(&#039;signup-form&#039;);\n\n\/\/ Adds a listener for the &quot;submit&quot; event.\nform.addEventListener(&#039;submit&#039;, function(event) {\n\n  \/\/ Prevents the browser from submitting the form\n  \/\/ and thus unloading the current page.\n  event.preventDefault();\n\n  \/\/ Creates a timeout to call submitForm after one second.\n  setTimeout(submitForm, 1000);\n\n  \/\/ Monitors whether or not the form has been submitted.\n  \/\/ This prevents the form from being submitted twice in cases\n  \/\/ where the event callback function fires normally.\n  var formSubmitted = false;\n\n  function submitForm() {\n    if (!formSubmitted) {\n      formSubmitted = true;\n      form.submit();\n    }\n  }\n\n  \/\/ Sends the event to Google Analytics and\n  \/\/ resubmits the form once the hit is done.\n  gtag(&#039;event&#039;, &#039;signup_form_complete&#039;, {\n    &#039;event_callback&#039;: submitForm\n  });\n});<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>gtag.js \u3067Google \u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306b\u30a4\u30d9\u30f3\u30c8\u3092\u9001\u4fe1\u3057\u305f\u3042\u3068\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3067\u6b21\u306e\u51e6\u7406\u306b\u9032\u3082\u3046\u3068\u3059\u308b\u5834\u5408\u3001\u5fc5\u305a\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u51e6\u7406\u3092\u4ed8\u3051\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3002 gtags.js \u304c\u6b63\u3057\u304f\u8aad\u307f\u8fbc\u307e\u308c\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u3001\u30a4\u30d9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3958,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[39],"class_list":["post-4072","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-javascript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=4072"}],"version-history":[{"count":1,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4072\/revisions"}],"predecessor-version":[{"id":4073,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4072\/revisions\/4073"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/3958"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=4072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=4072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=4072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}