{"id":13074,"date":"2026-03-13T18:07:01","date_gmt":"2026-03-13T18:07:01","guid":{"rendered":"https:\/\/withcode.tech\/media\/?p=13074"},"modified":"2026-07-01T15:28:43","modified_gmt":"2026-07-01T15:28:43","slug":"astro-ga4-partytown","status":"publish","type":"post","link":"https:\/\/withcode.tech\/media\/astro-ga4-partytown\/","title":{"rendered":"Astro\u306bGoogle Analytics 4\u3092Partytown\u3067\u5c0e\u5165\u3059\u308b\u65b9\u6cd5\u3010\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3011"},"content":{"rendered":"\n<div class=\"wp-block-group swl-box\"><div class=\"wp-block-group__inner-container\">\n\n<h3 class=\"wp-block-heading\">\u3053\u306e\u8a18\u4e8b\u3067\u308f\u304b\u308b\u3053\u3068<\/h3>\n\n\n<ul class=\"wp-block-list\">\n<li>GA4\u3092Astro\u3067\u4f7f\u3046\u3068PageSpeed\u304c\u4e0b\u304c\u308b\u7406\u7531\u3068Partytown\u306b\u3088\u308b\u89e3\u6c7a\u7b56<\/li>\n<li><code>npx astro add partytown<\/code> \u304b\u3089 <code>forward<\/code> \u8a2d\u5b9a\u307e\u3067\u306e\u5b8c\u5168\u306a\u624b\u9806<\/li>\n<li><code>GoogleAnalytics.astro<\/code> \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5b9f\u88c5\u30b3\u30fc\u30c9\u5168\u6587<\/li>\n<li><code>import.meta.env.PROD<\/code> \u3067\u672c\u756a\u74b0\u5883\u306e\u307f\u8a08\u6e2c\u3059\u308b\u65b9\u6cd5<\/li>\n<li>\u3088\u304f\u3042\u308b\u30c8\u30e9\u30d6\u30eb\uff08\u30a4\u30d9\u30f3\u30c8\u672a\u8a08\u6e2c\u30fb\u30b3\u30f3\u30bd\u30fc\u30eb\u30a8\u30e9\u30fc\uff09\u306e\u539f\u56e0\u3068\u5bfe\u51e6\u6cd5<\/li>\n<\/ul>\n\n<\/div><\/div>\n\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-left\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-14.48.08.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u751f\u5f92<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n<p class=\"balloon balloon-left\"><strong>Astro\u30b5\u30a4\u30c8\u306bGoogle Analytics 4\u3092\u5165\u308c\u305f\u3089\u3001PageSpeed Insights\u306e\u30b9\u30b3\u30a2\u304c\u30ac\u30af\u30c3\u3068B\u4e0b\u304c\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u4e0b\u3052\u305a\u306bGA4\u3092\u5c0e\u5165\u3059\u308b\u65b9\u6cd5\u3063\u3066\u3042\u308a\u307e\u3059\u304b\uff1f<\/strong><\/p>\n<span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-right\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-15.11.23.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u30da\u30f3\u535a\u58eb<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n<p class=\"balloon balloon-right\"><strong>\u3088\u30fc\u304f\u805e\u304f\u3093\u3060\u305e\u3002\u305d\u308c\u306f\u300cPartytown\u300d\u3092\u4f7f\u3048\u3070\u307b\u307c\u89e3\u6c7a\u3067\u304d\u308b\u3093\u3058\u3083\uff01Partytown\u306fGoogle\u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306e\u3088\u3046\u306a\u91cd\u3044\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092Web\u30ef\u30fc\u30ab\u30fc\u3068\u3044\u3046\u5225\u30b9\u30ec\u30c3\u30c9\u3067\u52d5\u304b\u3059\u3053\u3068\u3067\u3001\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3078\u306e\u5f71\u97ff\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u3066\u304f\u308c\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3058\u3083\u3002\u4eca\u65e5\u306fAstro + GA4 + Partytown\u306e\u5c0e\u5165\u624b\u9806\u3092\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u5fb9\u5e95\u89e3\u8aac\u3059\u308b\u305e\u3044\uff01<\/strong><\/p>\n<span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n\n<p class=\"wp-block-paragraph\">Astro\u3067\u4f5c\u3063\u305f\u30b5\u30a4\u30c8\u306bGoogle Analytics 4\uff08GA4\uff09\u3092\u666e\u901a\u306b\u8a2d\u7f6e\u3059\u308b\u3068\u3001\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u8aad\u307f\u8fbc\u307f\u304c\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3092\u30d6\u30ed\u30c3\u30af\u3057\u3001Core Web Vitals\u306e\u30b9\u30b3\u30a2\u304c\u4e0b\u304c\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u300c\u8a08\u6e2c\u3057\u305f\u3044\u3051\u3069\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3082\u843d\u3068\u3057\u305f\u304f\u306a\u3044\u300d\u3068\u3044\u3046\u30b8\u30ec\u30f3\u30de\u306fAstro\u30e6\u30fc\u30b6\u30fc\u304c\u5171\u901a\u3057\u3066\u76f4\u9762\u3059\u308b\u8ab2\u984c\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b9f\u969b\u3001GA4\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u5916\u90e8CDN\u304b\u3089\u8aad\u307f\u8fbc\u3080100KB\u8d85\u306eJavaScript\u3067\u3001\u4f4e\u901f\u56de\u7dda\u3084\u30e2\u30d0\u30a4\u30eb\u3067\u306f\u8868\u793a\u901f\u5ea6\u306b\u7121\u8996\u3067\u304d\u306a\u3044\u5f71\u97ff\u3092\u4e0e\u3048\u307e\u3059\u3002Partytown\u3092\u4f7f\u3063\u3066Web\u30ef\u30fc\u30ab\u30fc\u306b\u9003\u304c\u3059\u3053\u3068\u3067\u3001\u540c\u3058\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3092\u6c5a\u67d3\u305b\u305a\u306b\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u8a18\u4e8b\u3067\u306f\u3001<strong><span class=\"swl-marker mark_yellow\">Astro\u30b5\u30a4\u30c8\u306bGoogle Analytics 4\u3092Partytown\u3067\u5c0e\u5165\u3059\u308b4\u30b9\u30c6\u30c3\u30d7\u3068\u3001\u672c\u756a\u74b0\u5883\u306e\u307f\u8aad\u307f\u8fbc\u3080\u74b0\u5883\u5909\u6570\u306e\u8a2d\u5b9a\u3001\u52d5\u4f5c\u78ba\u8a8d\u306e\u65b9\u6cd5<\/span><\/strong>\u3092\u3059\u3079\u3066\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Partytown\u3068\u306f\u4f55\u304b\uff5c\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092Web\u30ef\u30fc\u30ab\u30fc\u306b\u9003\u304c\u3057\u3066\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5b88\u308b\u4ed5\u7d44\u307f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Partytown\u3092\u4f7f\u3046\u524d\u306b\u3001\u300c\u306a\u305c\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u4e0b\u3052\u308b\u306e\u304b\u300d\u3068\u300cPartytown\u304c\u3069\u3046\u89e3\u6c7a\u3059\u308b\u306e\u304b\u300d\u3092\u7406\u89e3\u3057\u3066\u304a\u304f\u3068\u3001\u8a2d\u5b9a\u5185\u5bb9\u304c\u8151\u306b\u843d\u3061\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/partytown_overview.png\" alt=\"Partytown\u304c\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092Web\u30ef\u30fc\u30ab\u30fc\u306b\u5206\u96e2\u3059\u308b\u4ed5\u7d44\u307f\u306e\u6982\u5ff5\u56f3\" class=\"wp-image-12410\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u901a\u5e38\u306eGA4\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u554f\u984c\u70b9<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010\u901a\u5e38\u306eGA4\u30b9\u30af\u30ea\u30d7\u30c8\u304cPageSpeed\u3092\u4e0b\u3052\u308b\u7406\u7531\u3011\n\n\u30d6\u30e9\u30a6\u30b6\u306e\u69cb\u9020\uff1a\n\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\uff081\u672c\uff09\n \u251c\u2500 HTML\u306e\u89e3\u6790\u30fbDOM\u306e\u69cb\u7bc9\n \u251c\u2500 CSS\u306e\u8a08\u7b97\u30fb\u30ec\u30a4\u30a2\u30a6\u30c8\n \u251c\u2500 JavaScript\u306e\u5b9f\u884c   \u2190 \u3053\u3053\u3067\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3082\u5b9f\u884c\u3055\u308c\u308b\n \u2514\u2500 \u63cf\u753b\uff08Paint \/ Composite\uff09\n\n\u554f\u984c\uff1a\n\u2192 GA4\u306e\u30b9\u30af\u30ea\u30d7\u30c8\uff08\u5916\u90e8CDN\u304b\u3089100KB\u8d85\uff09\u304c\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\u3055\u308c\u308b\n\u2192 \u5b9f\u884c\u4e2d\u3001\u30da\u30fc\u30b8\u306e\u63cf\u753b\u30fb\u30e6\u30fc\u30b6\u30fc\u64cd\u4f5c\u3078\u306e\u5fdc\u7b54\u304c\u30d6\u30ed\u30c3\u30af\u3055\u308c\u308b\n\u2192 FID\uff08First Input Delay\uff09\u30fbTBT\uff08Total Blocking Time\uff09\u304c\u60aa\u5316\u3059\u308b\n\u2192 Core Web Vitals \u30b9\u30b3\u30a2\u304c\u4e0b\u304c\u308b<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Partytown\u306e\u89e3\u6c7a\u7b56<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010Partytown\u3092\u4f7f\u3046\u3068\u4f55\u304c\u5909\u308f\u308b\u304b\u3011\n\n\u30d6\u30e9\u30a6\u30b6\u306e\u69cb\u9020\uff08Partytown\u5c0e\u5165\u5f8c\uff09\uff1a\n\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9               Web\u30ef\u30fc\u30ab\u30fc\uff08\u5225\u30b9\u30ec\u30c3\u30c9\uff09\n \u251c\u2500 HTML\u306e\u89e3\u6790\u30fbDOM\u69cb\u7bc9      \u2502\n \u251c\u2500 CSS\u306e\u8a08\u7b97\u30fb\u30ec\u30a4\u30a2\u30a6\u30c8    \u2502  \u2190 GA4\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u3053\u3053\u3067\u52d5\u304f\n \u251c\u2500 JS\u306e\u5b9f\u884c\uff08\u8efd\u304f\u306a\u308b\uff01\uff09   \u2502     \u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u306b\u5f71\u97ff\u30bc\u30ed\n \u2514\u2500 \u63cf\u753b\uff08\u9ad8\u901f\uff01\uff09           \u2502\n\n\u52b9\u679c\uff1a\n\u2705 \u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u306e\u30d6\u30ed\u30c3\u30af\u6642\u9593\u304c\u5927\u5e45\u306b\u6e1b\u5c11\n\u2705 FID \/ TBT \u306e\u6539\u5584 \u2192 Core Web Vitals \u304c\u5411\u4e0a\n\u2705 PageSpeed Insights \u306e\u30b9\u30b3\u30a2\u304c\u4e0a\u304c\u308b\n\u2705 GA4\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0\u306f\u901a\u5e38\u901a\u308a\u52d5\u4f5c\u3059\u308b\uff08\u8a08\u6e2c\u7cbe\u5ea6\u306b\u5f71\u97ff\u306a\u3057\uff09\n\n\u6ce8\u610f\u70b9\uff1a\n\u274c window \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u306e\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u306f\u5236\u9650\u3055\u308c\u308b\n   \u2192 forward \u30aa\u30d7\u30b7\u30e7\u30f3\u3067 dataLayer.push \u3092\u8ee2\u9001\u3059\u308b\u8a2d\u5b9a\u304c\u5fc5\u8981<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5bfe\u5fdc\u30d0\u30fc\u30b8\u30e7\u30f3<\/h3>\n\n\n<table>\n  <thead>\n    <tr><th>\u30d1\u30c3\u30b1\u30fc\u30b8<\/th><th>\u52d5\u4f5c\u78ba\u8a8d\u30d0\u30fc\u30b8\u30e7\u30f3<\/th><\/tr>\n  <\/thead>\n  <tbody>\n    <tr><td>Astro<\/td><td>5.0.5 \u4ee5\u964d<\/td><\/tr>\n    <tr><td>@astrojs\/partytown<\/td><td>2.1.3 \u4ee5\u964d<\/td><\/tr>\n    <tr><td>Node.js<\/td><td>18.x \u4ee5\u964d\u63a8\u5968<\/td><\/tr>\n  <\/tbody>\n<\/table>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u624b\u98061\uff1aGoogle Analytics 4\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u307e\u305a\u306fGA4\u306e\u7ba1\u7406\u753b\u9762\u304b\u3089\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u3059\u3067\u306b\u53d6\u5f97\u6e08\u307f\u306e\u5834\u5408\u306f\u3053\u306e\u624b\u9806\u3092\u8aad\u307f\u98db\u3070\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/ga4_tracking_id.png\" alt=\"Google Analytics 4\u306e\u7ba1\u7406\u753b\u9762\u3067\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u3092\u53d6\u5f97\u3059\u308b\u624b\u9806\u306e\u753b\u9762\u56f3\" class=\"wp-image-12411\"\/><\/figure>\n<\/div>\n\n\n<ol class=\"wp-block-list\">\n  <li><a href=\"https:\/\/analytics.google.com\/\" target=\"_blank\" rel=\"noopener\">Google Analytics<\/a> \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066Google\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u30ed\u30b0\u30a4\u30f3<\/li>\n  <li>\u300c\u7ba1\u7406\u300d\u2192\u300c\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f5c\u6210\u300d\u304b\u3089GA4\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u65b0\u898f\u4f5c\u6210\uff08\u65e2\u5b58\u306a\u3089\u5bfe\u8c61\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u9078\u629e\uff09<\/li>\n  <li>\u300c\u30c7\u30fc\u30bf\u30b9\u30c8\u30ea\u30fc\u30e0\u300d\u2192\u300c\u30a6\u30a7\u30d6\u300d\u3092\u9078\u629e\u3057\u3066\u30b5\u30a4\u30c8\u306eURL\u3068\u30b9\u30c8\u30ea\u30fc\u30e0\u540d\u3092\u5165\u529b<\/li>\n  <li>\u4f5c\u6210\u3055\u308c\u305f\u30b9\u30c8\u30ea\u30fc\u30e0\u306e\u300c\u6e2c\u5b9aID\u300d\u3092\u78ba\u8a8d\u3059\u308b\uff08<code>G-XXXXXXXXXX<\/code> \u5f62\u5f0f\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010\u53d6\u5f97\u3059\u308b\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u3011\n\nG-XXXXXXXXXX  \u2190 \u3053\u306e\u5f62\u5f0f\u306e\u6587\u5b57\u5217\uff08X \u306e\u90e8\u5206\u306f\u82f1\u6570\u5b57\uff09\n\n\u30fb\u300cG-\u300d\u304b\u3089\u59cb\u307e\u308b\u6587\u5b57\u5217\u304c\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\n\u30fb\u5f8c\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u4f5c\u6210\u3067\u4f7f\u7528\u3059\u308b\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304f\n\u30fb\u7d76\u5bfe\u306b\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u76f4\u66f8\u304d\u3057\u306a\u3044\n  \u2192 \u74b0\u5883\u5909\u6570\uff08.env\uff09\u306b\u4fdd\u5b58\u3059\u308b\u306e\u304c\u5b89\u5168<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u624b\u98062\uff1aPartytown\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066 astro.config.mjs \u3092\u8a2d\u5b9a\u3059\u308b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Astro\u306b\u306f\u516c\u5f0f\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066 <code>@astrojs\/partytown<\/code> \u304c\u7528\u610f\u3055\u308c\u3066\u304a\u308a\u3001\u30b3\u30de\u30f3\u30c91\u3064\u3067\u8a2d\u5b9a\u307e\u3067\u81ea\u52d5\u3067\u884c\u3048\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/astro_partytown_install.png\" alt=\"Partytown\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068astro.config.mjs\u306e\u8a2d\u5b9a\u624b\u9806\u56f3\" class=\"wp-image-12412\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30b3\u30de\u30f3\u30c9<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Astro\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8\u3067\u5b9f\u884c\u3059\u308b\nnpx astro add partytown<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u78ba\u8a8d\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u3059\u3079\u3066 <code>y<\/code> \u3067\u9032\u3081\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u2714 Continue? \u2026 yes\n\u2714 @astrojs\/partytown \u3092 package.json \u306b\u8ffd\u52a0\u3057\u307e\u3059\u304b\uff1f \u2026 yes\n\u2714 astro.config.mjs \u3092\u66f4\u65b0\u3057\u307e\u3059\u304b\uff1f \u2026 yes<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">astro.config.mjs \u306e\u8a2d\u5b9a\uff08forward\u30aa\u30d7\u30b7\u30e7\u30f3\u5fc5\u9808\uff09<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u81ea\u52d5\u8ffd\u52a0\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306b\u3001<strong><code>forward: [\"dataLayer.push\"]<\/code> \u306e\u8a2d\u5b9a\u3092\u5fc5\u305a\u8ffd\u8a18<\/strong>\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u8a2d\u5b9a\u304c\u306a\u3044\u3068GA4\u306e\u30a4\u30d9\u30f3\u30c8\u304cWeb\u30ef\u30fc\u30ab\u30fc\u304b\u3089\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3078\u6b63\u3057\u304f\u8ee2\u9001\u3055\u308c\u305a\u3001\u8a08\u6e2c\u304c\u6a5f\u80fd\u3057\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ astro.config.mjs\nimport { defineConfig } from \"astro\/config\";\nimport partytown from \"@astrojs\/partytown\";\n\nexport default defineConfig({\n  integrations: [\n    partytown({\n      config: {\n        \/\/ dataLayer.push \u3092Web\u30ef\u30fc\u30ab\u30fc\u304b\u3089\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3078\u8ee2\u9001\u3059\u308b\n        \/\/ \u2190 \u3053\u306e\u8a2d\u5b9a\u304c\u306a\u3044\u3068GA4\u306e\u30a4\u30d9\u30f3\u30c8\u304c\u8a08\u6e2c\u3055\u308c\u306a\u3044\n        forward: [\"dataLayer.push\"],\n      },\n    }),\n  ],\n});<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010forward \u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u306a\u7406\u7531\u3011\n\n\u554f\u984c\u306e\u80cc\u666f\uff1a\n\u2192 Web\u30ef\u30fc\u30ab\u30fc\u306f\u30d6\u30e9\u30a6\u30b6\u306eAPI\u306e\u4e00\u90e8\uff08window\u30fbdocument\u306a\u3069\uff09\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044\n\u2192 GA4\u306f\u5185\u90e8\u3067 window.dataLayer.push() \u3092\u547c\u3073\u51fa\u3057\u3066\u30a4\u30d9\u30f3\u30c8\u3092\u8a18\u9332\u3059\u308b\n\u2192 \u30b9\u30af\u30ea\u30d7\u30c8\u3092Web\u30ef\u30fc\u30ab\u30fc\u306b\u79fb\u3059\u3068\u3001window \u304c\u53c2\u7167\u3067\u304d\u305a\u30a4\u30d9\u30f3\u30c8\u304c\u6d88\u3048\u308b\n\n\u89e3\u6c7a\u7b56\uff1a\n\u2192 forward \u306b \"dataLayer.push\" \u3092\u6307\u5b9a\u3059\u308b\u3068\n   Partytown\u304c\u30c0\u30df\u30fc\u306e dataLayer.push \u3092\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u306b\u4f5c\u6210\u3059\u308b\n   Web\u30ef\u30fc\u30ab\u30fc\u306eGA4\u304c dataLayer.push \u3092\u547c\u3076\n   \u2192 \u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u306e\u30c0\u30df\u30fc\u304c\u53d7\u3051\u53d6\u3063\u3066\u672c\u7269\u306e dataLayer.push \u306b\u6e21\u3059\n\n\u25b6 forward \u306e\u8a2d\u5b9a\u306fPartytown\u5c0e\u5165\u3067\u6700\u3082\u3088\u304f\u30df\u30b9\u3059\u308b\u30dd\u30a4\u30f3\u30c8\u306a\u306e\u3067\u8981\u6ce8\u610f<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u624b\u98063\uff1aGoogleAnalytics.astro\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GA4\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0\u30b3\u30fc\u30c9\u30921\u304b\u6240\u306b\u307e\u3068\u3081\u305fAstro\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5316\u3059\u308b\u3053\u3068\u3067\u3001Layout.astro\u304b\u30891\u884c\u3067\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/ga4_astro_component.png\" alt=\"GoogleAnalytics.astro\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u4f5c\u6210\u624b\u9806\u3068\u30d5\u30a1\u30a4\u30eb\u914d\u7f6e\u56f3\" class=\"wp-image-12413\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u5834\u6240<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>src\/\n\u251c\u2500\u2500 components\/\n\u2502   \u2514\u2500\u2500 GoogleAnalytics.astro  \u2190 \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u65b0\u898f\u4f5c\u6210\n\u251c\u2500\u2500 layouts\/\n\u2502   \u2514\u2500\u2500 Layout.astro\n\u2514\u2500\u2500 pages\/\n    \u2514\u2500\u2500 index.astro<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">GoogleAnalytics.astro\u306e\u30b3\u30fc\u30c9<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- src\/components\/GoogleAnalytics.astro --&gt;\n\n&lt;!--\n  \u91cd\u8981\uff1ascript \u30bf\u30b0\u306b type=\"text\/partytown\" \u3092\u6307\u5b9a\u3059\u308b\n  \u2192 \u3053\u308c\u304c\u306a\u3044\u3068Web\u30ef\u30fc\u30ab\u30fc\u3067\u306f\u306a\u304f\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3067\u5b9f\u884c\u3055\u308c\u3066\u3057\u307e\u3046\n--&gt;\n\n&lt;!-- \u2460 GA4\u306e\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u975e\u540c\u671f\u3067\u8aad\u307f\u8fbc\u3080 --&gt;\n&lt;script\n  type=\"text\/partytown\"\n  async\n  src=\"https:\/\/www.googletagmanager.com\/gtag\/js?id=G-XXXXXXXXXX\"\n&gt;&lt;\/script&gt;\n\n&lt;!-- \u2461 GA4\u306e\u521d\u671f\u8a2d\u5b9a\u30b9\u30af\u30ea\u30d7\u30c8 --&gt;\n&lt;script type=\"text\/partytown\"&gt;\n  window.dataLayer = window.dataLayer || [];\n  function gtag() { dataLayer.push(arguments); }\n  gtag(\"js\", new Date());\n  gtag(\"config\", \"G-XXXXXXXXXX\");\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>G-XXXXXXXXXX<\/code> \u306e\u90e8\u5206\u3092\u624b\u98061\u3067\u53d6\u5f97\u3057\u305f\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u306b\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u74b0\u5883\u5909\u6570\u3067\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u3092\u7ba1\u7406\u3059\u308b\uff08\u63a8\u5968\uff09<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u3092\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u76f4\u66f8\u304d\u3059\u308b\u3068\u3001GitHub\u306a\u3069\u306b\u8aa4\u3063\u3066\u516c\u958b\u3057\u3066\u3057\u307e\u3046\u30ea\u30b9\u30af\u304c\u3042\u308a\u307e\u3059\u3002<strong>\u74b0\u5883\u5909\u6570\u3067\u7ba1\u7406\u3059\u308b\u306e\u304c\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/strong>\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># .env\uff08\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30eb\u30fc\u30c8\u306b\u4f5c\u6210\uff09\nPUBLIC_GA_TRACKING_ID=G-XXXXXXXXXX\n\n# .env \u306f\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u542b\u3081\u306a\u3044\uff01\n# .gitignore \u306b .env \u3092\u8ffd\u8a18\u3057\u3066\u304a\u304f<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- src\/components\/GoogleAnalytics.astro\uff08\u74b0\u5883\u5909\u6570\u7248\uff09 --&gt;\n---\n\/\/ Astro\u3067\u306f PUBLIC_ \u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u306e\u3064\u3044\u305f\u74b0\u5883\u5909\u6570\u304c\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u516c\u958b\u3055\u308c\u308b\nconst trackingId = import.meta.env.PUBLIC_GA_TRACKING_ID;\n---\n\n&lt;script\n  type=\"text\/partytown\"\n  async\n  src={`https:\/\/www.googletagmanager.com\/gtag\/js?id=${trackingId}`}\n&gt;&lt;\/script&gt;\n\n&lt;script type=\"text\/partytown\" define:vars={{ trackingId }}&gt;\n  window.dataLayer = window.dataLayer || [];\n  function gtag() { dataLayer.push(arguments); }\n  gtag(\"js\", new Date());\n  gtag(\"config\", trackingId);\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010Astro\u306e\u74b0\u5883\u5909\u6570\u306e\u4f7f\u3044\u5206\u3051\u3011\n\nPUBLIC_ \u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u3042\u308a\uff08\u4f8b\uff1aPUBLIC_GA_TRACKING_ID\uff09\n\u2192 \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\uff08\u30d6\u30e9\u30a6\u30b6\uff09\u3067\u3082\u53c2\u7167\u3067\u304d\u308b\n\u2192 \u30d3\u30eb\u30c9\u5f8c\u306eJS\u306b\u542b\u307e\u308c\u308b\n\u2192 GA4\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u306a\u3069\u300c\u516c\u958b\u3055\u308c\u3066\u3082\u554f\u984c\u306a\u3044\u5024\u300d\u306b\u4f7f\u3046\n\nPUBLIC_ \u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u306a\u3057\uff08\u4f8b\uff1aSECRET_API_KEY\uff09\n\u2192 \u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\uff08.astro\u30d5\u30a1\u30a4\u30eb\u306efrontmatter\uff09\u306e\u307f\u53c2\u7167\u53ef\u80fd\n\u2192 \u30d6\u30e9\u30a6\u30b6\u306eJS\u306b\u306f\u7d76\u5bfe\u306b\u542b\u307e\u308c\u306a\u3044\n\u2192 API\u30ad\u30fc\u30fb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u60c5\u5831\u306a\u3069\u300c\u79d8\u5bc6\u306b\u3059\u3079\u304d\u5024\u300d\u306b\u4f7f\u3046<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u624b\u98064\uff1aLayout.astro\u306ehead\u30bf\u30b0\u306b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u57cb\u3081\u8fbc\u3080<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f5c\u6210\u3057\u305f <code>GoogleAnalytics.astro<\/code> \u3092 <code>Layout.astro<\/code> \u306e <code>&lt;head&gt;<\/code> \u5185\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/layout_astro_ga4.png\" alt=\"Layout.astro\u306bGoogleAnalytics\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u57cb\u3081\u8fbc\u3080\u624b\u9806\u56f3\" class=\"wp-image-12414\"\/><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- src\/layouts\/Layout.astro --&gt;\n---\nimport GoogleAnalytics from '..\/components\/GoogleAnalytics.astro';\n---\n\n&lt;!DOCTYPE html&gt;\n&lt;html lang=\"ja\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"UTF-8\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;link rel=\"icon\" type=\"image\/svg+xml\" href=\"\/favicon.svg\" \/&gt;\n    &lt;meta name=\"generator\" content={Astro.generator} \/&gt;\n    &lt;title&gt;{title}&lt;\/title&gt;\n\n    &lt;!-- GoogleAnalytics \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092 head \u5185\u306b\u914d\u7f6e --&gt;\n    &lt;GoogleAnalytics \/&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;slot \/&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u6642\u70b9\u3067GA4\u306f\u5168\u30da\u30fc\u30b8\u306b\u9069\u7528\u3055\u308c\u307e\u3059\u3002\u305f\u3060\u3057<strong>\u3053\u306e\u307e\u307e\u3067\u306f\u958b\u767a\u74b0\u5883\u3067\u3082\u8a08\u6e2c\u3055\u308c\u3066\u3057\u307e\u3046<\/strong>\u305f\u3081\u3001\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u672c\u756a\u74b0\u5883\u306e\u307f\u306b\u7d5e\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u672c\u756a\u74b0\u5883\u306e\u307fGA4\u3092\u8aad\u307f\u8fbc\u3080\uff5cimport.meta.env.PROD\u3067\u74b0\u5883\u3092\u5224\u5b9a\u3059\u308b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u958b\u767a\u74b0\u5883\u3067\u3082GA4\u304c\u52d5\u3044\u3066\u3044\u308b\u3068\u81ea\u5206\u306e\u30a2\u30af\u30bb\u30b9\u304c\u8a08\u6e2c\u30c7\u30fc\u30bf\u306b\u6df7\u5165\u3057\u3001\u6570\u5024\u304c\u6b63\u78ba\u3067\u306a\u304f\u306a\u308a\u307e\u3059\u3002<strong><code>import.meta.env.PROD<\/code> \u3067\u672c\u756a\u74b0\u5883\u306e\u307fGA4\u3092\u8aad\u307f\u8fbc\u3080<\/strong>\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/astro_env_prod.png\" alt=\"import.meta.env.PROD\u3092\u4f7f\u3063\u3066\u672c\u756a\u74b0\u5883\u306e\u307fGA4\u3092\u8aad\u307f\u8fbc\u3080\u5b9f\u88c5\u56f3\" class=\"wp-image-12415\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">Layout.astro\u306e\u4fee\u6b63<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- src\/layouts\/Layout.astro\uff08\u672c\u756a\u74b0\u5883\u306e\u307fGA4\u3092\u8aad\u307f\u8fbc\u3080\u7248\uff09 --&gt;\n---\nimport GoogleAnalytics from '..\/components\/GoogleAnalytics.astro';\n\n\/\/ import.meta.env.PROD\n\/\/ \u2192 \u672c\u756a\u30d3\u30eb\u30c9\uff08npm run build\uff09\u306e\u3068\u304d true\n\/\/ \u2192 \u958b\u767a\u30b5\u30fc\u30d0\u30fc\uff08npm run dev\uff09\u306e\u3068\u304d false\nconst isProd = import.meta.env.PROD;\n---\n\n&lt;!DOCTYPE html&gt;\n&lt;html lang=\"ja\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"UTF-8\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;link rel=\"icon\" type=\"image\/svg+xml\" href=\"\/favicon.svg\" \/&gt;\n    &lt;meta name=\"generator\" content={Astro.generator} \/&gt;\n    &lt;title&gt;{title}&lt;\/title&gt;\n\n    &lt;!-- isProd \u304c true \u306e\u3068\u304d\u3060\u3051 GoogleAnalytics \u3092\u8868\u793a\u3059\u308b --&gt;\n    {isProd &amp;&amp; &lt;GoogleAnalytics \/&gt;}\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;slot \/&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010Astro\u306e\u74b0\u5883\u5909\u6570\u307e\u3068\u3081\u3011\n\nimport.meta.env.PROD\n\u2192 npm run build \u3067\u751f\u6210\u3057\u305f\u672c\u756a\u30d3\u30eb\u30c9\u306e\u3068\u304d true\n\u2192 npm run dev\uff08\u958b\u767a\u30b5\u30fc\u30d0\u30fc\uff09\u306e\u3068\u304d false\n\nimport.meta.env.DEV\n\u2192 \u958b\u767a\u30b5\u30fc\u30d0\u30fc\u306e\u3068\u304d true\uff08PROD\u306e\u9006\uff09\n\nimport.meta.env.MODE\n\u2192 \"production\" \u307e\u305f\u306f \"development\" \u306e\u6587\u5b57\u5217\n\nimport.meta.env.BASE_URL\n\u2192 astro.config.mjs \u306e base \u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u5024\n\n\u6d3b\u7528\u4f8b\uff1a\n{import.meta.env.PROD &amp;&amp; &lt;GoogleAnalytics \/&gt;}\n\u2192 \u672c\u756a\u306e\u307fGA4\u3092\u8aad\u307f\u8fbc\u3080\uff08\u958b\u767a\u4e2d\u306f\u8a08\u6e2c\u3057\u306a\u3044\uff09\n\n{import.meta.env.DEV &amp;&amp; &lt;DebugPanel \/&gt;}\n\u2192 \u958b\u767a\u4e2d\u3060\u3051\u30c7\u30d0\u30c3\u30b0\u30d1\u30cd\u30eb\u3092\u8868\u793a\u3059\u308b<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u52d5\u4f5c\u78ba\u8a8d\u306e\u65b9\u6cd5\uff5cGA4\u3068Partytown\u304c\u6b63\u3057\u304f\u52d5\u3044\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b3\u3064\u306e\u624b\u9806<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8a2d\u5b9a\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001GA4\u3068Partytown\u304c\u6b63\u3057\u304f\u52d5\u3044\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\u3002\u672c\u756a\u30d3\u30eb\u30c9\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001<code>npm run build<\/code> \u5f8c\u306b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/ga4_partytown_verification.png\" alt=\"GA4\u3068Partytown\u306e\u52d5\u4f5c\u78ba\u8a8d3\u30b9\u30c6\u30c3\u30d7\u306e\u624b\u9806\u56f3\" class=\"wp-image-12416\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u78ba\u8a8d\u624b\u98061\uff1a\u30d3\u30eb\u30c9\u3057\u3066\u30d7\u30ec\u30d3\u30e5\u30fc\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3059\u308b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u672c\u756a\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\nnpm run build\n\n# \u30d7\u30ec\u30d3\u30e5\u30fc\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\uff08\u672c\u756a\u30d3\u30eb\u30c9\u306e\u52d5\u4f5c\u78ba\u8a8d\u7528\uff09\nnpm run preview\n\n# \u2192 http:\/\/localhost:4321 \u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\n# \u2192 isProd \u304c true \u306b\u306a\u308b\u306e\u3067GA4\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u78ba\u8a8d\u624b\u98062\uff1a\u958b\u767a\u8005\u30c4\u30fc\u30eb\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bf\u30d6\u3067\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>1. \u30d6\u30e9\u30a6\u30b6\u3067 http:\/\/localhost:4321 \u3092\u958b\u304f\n2. F12\u3067\u958b\u767a\u8005\u30c4\u30fc\u30eb\u3092\u958b\u304f\n3. \u300cNetwork\u300d\u30bf\u30d6\u3092\u9078\u629e\n4. \u30d5\u30a3\u30eb\u30bf\u30fc\u306b\u300cgtag\u300d\u3068\u5165\u529b\n5. \u30da\u30fc\u30b8\u3092\u30ea\u30ed\u30fc\u30c9\n\n\u78ba\u8a8d\u30dd\u30a4\u30f3\u30c8\uff1a\n\u2705 \"googletagmanager.com\/gtag\/js?id=G-XXXXXXXXXX\" \u306e\u30ea\u30af\u30a8\u30b9\u30c8\u304c\n   \u300cInitiator: partytown\u300d\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u308c\u3070Web\u30ef\u30fc\u30ab\u30fc\u7d4c\u7531\u3067\u52d5\u3044\u3066\u3044\u308b\n\n\u274c Initiator\u304c\u901a\u5e38\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u306a\u3063\u3066\u3044\u308b\u5834\u5408\n\u2192 type=\"text\/partytown\" \u304c script \u30bf\u30b0\u306b\u3064\u3044\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u78ba\u8a8d\u624b\u98063\uff1aGA4\u306e\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30ec\u30dd\u30fc\u30c8\u3067\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>1. Google Analytics \u306e\u7ba1\u7406\u753b\u9762\u306b\u30a2\u30af\u30bb\u30b9\n2. \u5de6\u30e1\u30cb\u30e5\u30fc\u300c\u30ec\u30dd\u30fc\u30c8\u300d\u2192\u300c\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u300d\u3092\u958b\u304f\n3. \u30d7\u30ec\u30d3\u30e5\u30fc\u30b5\u30fc\u30d0\u30fc\uff08localhost:4321\uff09\u306e\u30da\u30fc\u30b8\u3092\u958b\u304f\n4. \u300c\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u6570\u300d\u304c1\u4ee5\u4e0a\u8868\u793a\u3055\u308c\u308c\u3070\u8a08\u6e2c\u6210\u529f\n\n\u6ce8\u610f\uff1a\n\u2192 localhost \u3067\u306e\u8a08\u6e2c\u306fGA\u306b\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3055\u308c\u308b\u5834\u5408\u304c\u3042\u308b\n   \u2192 \u672c\u756a\u74b0\u5883\u306b\u30c7\u30d7\u30ed\u30a4\u3057\u305f\u5f8c\u3067\u78ba\u8a8d\u3059\u308b\u306e\u304c\u78ba\u5b9f<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">PageSpeed Insights\u3067\u30b9\u30b3\u30a2\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010Partytown\u5c0e\u5165\u524d\u5f8c\u306ePageSpeed Insights\u306e\u5909\u5316\uff08\u76ee\u5b89\uff09\u3011\n\n\u8a08\u6e2c\u6307\u6a19              \u5c0e\u5165\u524d    \u5c0e\u5165\u5f8c\uff08\u76ee\u5b89\uff09\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nTBT\uff08Total Blocking Time\uff09\n                      100\u301c300ms \u2192  20\u301c80ms\nFID\uff08First Input Delay\uff09\n                      100ms\u8d85   \u2192  50ms\u4ee5\u4e0b\n\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30b9\u30b3\u30a2  70\u301c80    \u2192  85\u301c95\n\n\u203b \u30b5\u30a4\u30c8\u306e\u69cb\u6210\u3084\u4ed6\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u91cf\u306b\u3088\u3063\u3066\u52b9\u679c\u306f\u7570\u306a\u308b\n\u203b \u52b9\u679c\u3092\u6700\u5927\u5316\u3059\u308b\u306b\u306f\u3001\u4ed6\u306e\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\uff08\u5e83\u544a\u30fb\u30c1\u30e3\u30c3\u30c8\u7b49\uff09\u3082\n   \u540c\u69d8\u306bPartytown\u306b\u79fb\u3059\u3053\u3068\u3092\u691c\u8a0e\u3059\u308b<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u30c8\u30e9\u30d6\u30eb\u3068\u89e3\u6c7a\u65b9\u6cd5<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8a2d\u5b9a\u5f8c\u306b\u60f3\u5b9a\u901a\u308a\u306b\u52d5\u304b\u306a\u3044\u30b1\u30fc\u30b9\u3068\u3001\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5\u3092\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full\"><img decoding=\"async\" src=\"img\/partytown_troubleshooting.png\" alt=\"Partytown\u5c0e\u5165\u6642\u306e\u3088\u304f\u3042\u308b\u30c8\u30e9\u30d6\u30eb\u3068\u89e3\u6c7a\u7b56\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\" class=\"wp-image-12417\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u30c8\u30e9\u30d6\u30eb1\uff1aGA4\u304c\u30a4\u30d9\u30f3\u30c8\u3092\u8a08\u6e2c\u3057\u306a\u3044<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3010\u539f\u56e0\u3068\u5bfe\u51e6\u6cd5\u3011\n\n\u539f\u56e0A\uff1aastro.config.mjs \u306b forward: [\"dataLayer.push\"] \u3092\u66f8\u304d\u5fd8\u308c\u3066\u3044\u308b\n\u5bfe\u51e6\uff1aastro.config.mjs \u3092\u78ba\u8a8d\u3057\u3066 forward \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u8a18\u3059\u308b\n\n\u539f\u56e0B\uff1ascript \u30bf\u30b0\u306b type=\"text\/partytown\" \u3092\u4ed8\u3051\u5fd8\u308c\u3066\u3044\u308b\n\u5bfe\u51e6\uff1aGoogleAnalytics.astro \u306e\u4e21\u65b9\u306e script \u30bf\u30b0\u306b\n     type=\"text\/partytown\" \u304c\u4ed8\u3044\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b\n\n\u539f\u56e0C\uff1a\u958b\u767a\u30b5\u30fc\u30d0\u30fc\uff08npm run dev\uff09\u3067\u78ba\u8a8d\u3057\u3066\u3044\u308b\n\u5bfe\u51e6\uff1anpm run build &amp;&amp; npm run preview \u3067\u30d3\u30eb\u30c9\u5f8c\u306b\u78ba\u8a8d\u3059\u308b\n     \uff08isProd \u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u3001dev \u3067\u306f\u8aad\u307f\u8fbc\u307e\u308c\u306a\u3044\uff09\n\n\u539f\u56e0D\uff1a\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u304c\u9593\u9055\u3063\u3066\u3044\u308b\n\u5bfe\u51e6\uff1aG- \u304b\u3089\u59cb\u307e\u308bID\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c8\u30e9\u30d6\u30eb2\uff1a\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u300cpartytown\u300d\u95a2\u9023\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u308b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u3088\u304f\u898b\u3089\u308c\u308b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\n\/\/ \"Partytown could not find 'dataLayer'\"\n\/\/ \u2192 forward \u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\n\n\/\/ astro.config.mjs \u3092\u78ba\u8a8d\u30fb\u4fee\u6b63\u3059\u308b\npartytown({\n  config: {\n    forward: [\"dataLayer.push\"],  \/\/ \u2190 \u3053\u308c\u304c\u5fc5\u8981\n  },\n})<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c8\u30e9\u30d6\u30eb3\uff1aGoogle Tag Manager\u3092Partytown\u3067\u52d5\u304b\u3057\u305f\u3044<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- GTM\u3092Partytown\u3067\u52d5\u304b\u3059\u5834\u5408\uff08GA4\u3067\u306f\u306a\u304fGTM\u7d4c\u7531\u306e\u5834\u5408\uff09 --&gt;\n&lt;script\n  type=\"text\/partytown\"\n  async\n  src=\"https:\/\/www.googletagmanager.com\/gtm.js?id=GTM-XXXXXXXX\"\n&gt;&lt;\/script&gt;\n\n&lt;script type=\"text\/partytown\"&gt;\n  window.dataLayer = window.dataLayer || [];\n  window.dataLayer.push({ \"gtm.start\": new Date().getTime(), event: \"gtm.js\" });\n&lt;\/script&gt;\n\n\/\/ astro.config.mjs \u306e forward \u3082\u66f4\u65b0\u304c\u5fc5\u8981\npartytown({\n  config: {\n    forward: [\"dataLayer.push\"],\n    \/\/ GTM\u72ec\u81ea\u306e\u30a4\u30d9\u30f3\u30c8\u3082\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u8ffd\u52a0\n  },\n})<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u8cea\u554f\uff08FAQ\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Q1. Partytown\u3092\u4f7f\u3046\u3068GA4\u306e\u8a08\u6e2c\u7cbe\u5ea6\u306f\u4e0b\u304c\u308a\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> \u57fa\u672c\u7684\u306b\u306f\u8a08\u6e2c\u7cbe\u5ea6\u306b\u5f71\u97ff\u3042\u308a\u307e\u305b\u3093\u3002Partytown\u306f<strong>\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u5834\u6240\uff08Web\u30ef\u30fc\u30ab\u30fc\uff09\u3092\u5909\u3048\u308b\u3060\u3051<\/strong>\u3067\u3001GA4\u306e\u8a08\u6e2c\u30ed\u30b8\u30c3\u30af\u81ea\u4f53\u306f\u5909\u308f\u3089\u306a\u3044\u304b\u3089\u3067\u3059\u3002\u305f\u3060\u3057\u3001<code>forward<\/code> \u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u30df\u30b9\u304c\u3042\u308b\u3068\u30a4\u30d9\u30f3\u30c8\u304c\u6b20\u843d\u3059\u308b\u5834\u5408\u304c\u3042\u308b\u305f\u3081\u3001\u52d5\u4f5c\u78ba\u8a8d\u306f\u5fc5\u305a\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q2. GA4\u4ee5\u5916\u306e\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3082Partytown\u3067\u52d5\u304b\u305b\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> \u306f\u3044\u3002Google Tag Manager\u30fbMeta Pixel\u30fbHotjar\u30fb\u30a4\u30f3\u30bf\u30fc\u30b3\u30e0\u306a\u3069\u306e\u591a\u304f\u306e\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092Partytown\u3067\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>type=\"text\/partytown\"<\/code> \u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u3067\u52d5\u304f\u3082\u306e\u3068\u3001<code>forward<\/code> \u30aa\u30d7\u30b7\u30e7\u30f3\u3078\u306e\u8ffd\u8a18\u304c\u5fc5\u8981\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002\u5404\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3084Partytown\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q3. Astro\u4ee5\u5916\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3082Partytown\u306f\u4f7f\u3048\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> \u4f7f\u3048\u307e\u3059\u3002<strong>Next.js\u30fbNuxt\u30fbSvelteKit\u30fbRemix<\/strong>\u306a\u3069\u4e3b\u8981\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u5411\u3051\u306e\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306a\u3057\u306eVanilla JS\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3082\u3001<code>@builder.io\/partytown<\/code> \u3092\u76f4\u63a5\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u4f7f\u3048\u307e\u3059\u3002\u57fa\u672c\u7684\u306a\u8003\u3048\u65b9\uff08<code>type=\"text\/partytown\"<\/code>\u30fb<code>forward<\/code>\u8a2d\u5b9a\uff09\u306f\u3069\u306e\u74b0\u5883\u3067\u3082\u5171\u901a\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q4. Astro 4.x \u304b\u3089 5.x \u3078\u306e\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3067\u8a2d\u5b9a\u304c\u5909\u308f\u308a\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> <code>@astrojs\/partytown<\/code> \u306e\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u65b9\u6cd5\u306fAstro 4.x \u3068 5.x \u3067\u5927\u304d\u304f\u5909\u308f\u308a\u307e\u305b\u3093\u3002\u305f\u3060\u3057\u3001Astro\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u6642\u306f <code>@astrojs\/partytown<\/code> \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3082\u5408\u308f\u305b\u3066\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3057\u3001\u516c\u5f0f\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30ac\u30a4\u30c9\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3092\u63a8\u5968\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q5. Vercel\u3084Netlify\u306b\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u3082\u52d5\u4f5c\u3057\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> \u52d5\u4f5c\u3057\u307e\u3059\u3002Partytown\u306f\u30d3\u30eb\u30c9\u6642\u306b\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u751f\u6210\u3055\u308c\uff08<code>public\/~partytown\/<\/code> \u4ee5\u4e0b\uff09\u3001\u30b5\u30fc\u30d0\u30fc\u306b\u4f9d\u5b58\u3057\u306a\u3044\u4ed5\u7d44\u307f\u3067\u52d5\u304d\u307e\u3059\u3002Vercel\u30fbNetlify\u30fbCloudflare Pages\u3044\u305a\u308c\u3082\u8ffd\u52a0\u8a2d\u5b9a\u306a\u3057\u3067\u4f7f\u3048\u307e\u3059\u3002\u30c7\u30d7\u30ed\u30a4\u5f8c\u306f\u5fc5\u305aGA4\u306e\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30ec\u30dd\u30fc\u30c8\u3067\u8a08\u6e2c\u3067\u304d\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-left\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-14.48.08.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u751f\u5f92<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n<p class=\"balloon balloon-left\"><strong>Partytown\u3063\u3066\u8a2d\u5b9a\u304c\u591a\u304f\u3066\u96e3\u3057\u305d\u3046\u306b\u898b\u3048\u307e\u3057\u305f\u304c\u3001\u3084\u3063\u3066\u307f\u305f\u3089\u610f\u5916\u3068\u7c21\u5358\u3067\u3057\u305f\uff01\u4ed6\u306b\u3082\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u4e0a\u3052\u308b\u65b9\u6cd5\u306f\u3042\u308a\u307e\u3059\u304b\uff1f<\/strong><\/p>\n<span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-right\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-15.11.23.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u30da\u30f3\u535a\u58eb<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n<p class=\"balloon balloon-right\"><strong>\u3088\u3044\u3053\u3068\u306b\u6c17\u304c\u3064\u3044\u305f\u306e\u3046\uff01Astro\u306f\u3082\u3068\u3082\u3068\u300c\u5fc5\u8981\u306aJavaScript\u3060\u3051\u9001\u308b\u300d\u3068\u3044\u3046\u8a2d\u8a08\u601d\u60f3\u304c\u3042\u308b\u304b\u3089\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u306f\u6709\u5229\u3058\u3083\u3002\u3055\u3089\u306b\u4e0a\u3092\u76ee\u6307\u3059\u306a\u3089\u3001\u753b\u50cf\u306e\u6700\u9069\u5316\uff08Astro Image\uff09\u30fb\u30d5\u30a9\u30f3\u30c8\u306e\u30b5\u30d6\u30bb\u30c3\u30c8\u5316\u30fbCSS\/JS\u306e\u30d0\u30f3\u30c9\u30eb\u30b5\u30a4\u30ba\u524a\u6e1b\u3082\u6709\u52b9\u3058\u3083\u305e\u3002WithCode\u3067HTML\/CSS\/JS\u306e\u57fa\u790e\u3092\u5b66\u3093\u3060\u4e0a\u3067Astro\u306b\u53d6\u308a\u7d44\u3080\u3068\u3001\u3053\u3046\u3057\u305f\u6700\u9069\u5316\u306e\u7406\u7531\u304c\u81ea\u7136\u306b\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3093\u3058\u3083\uff01<\/strong><\/p>\n<span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-left\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-15.06.05.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u751f\u5f92<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n<p class=\"balloon balloon-left\"><strong>\u306a\u308b\u307b\u3069\uff01\u57fa\u790e\u304c\u3042\u3063\u3066\u3053\u305d\u6700\u9069\u5316\u306e\u610f\u5473\u304c\u308f\u304b\u308b\u3093\u3067\u3059\u306d\u3002PageSpeed\u306e\u30b9\u30b3\u30a2\u304c\u4e0a\u304c\u3063\u305f\u77ac\u9593\u306f\u3059\u3054\u304f\u5b09\u3057\u304b\u3063\u305f\u3067\u3059\uff01\u5f15\u304d\u7d9a\u304d\u52c9\u5f37\u3057\u307e\u3059\uff01<\/strong><\/p>\n<span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u8a18\u4e8b\u3067\u306f\u3001Astro\u30b5\u30a4\u30c8\u306bGoogle Analytics 4\u3092Partytown\u3067\u5c0e\u5165\u3059\u308b\u65b9\u6cd5\u3068\u3057\u3066\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304b\u3089\u672c\u756a\u74b0\u5883\u306e\u8a2d\u5b9a\u30fb\u52d5\u4f5c\u78ba\u8a8d\u30fb\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u307e\u3067\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n  <li><strong>Partytown\u306e\u4ed5\u7d44\u307f<\/strong>\uff1a\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092Web\u30ef\u30fc\u30ab\u30fc\u306b\u79fb\u3059\u3053\u3068\u3067\u3001\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u3078\u306e\u5f71\u97ff\u3092\u6700\u5c0f\u9650\u306b\u3057\u3066Core Web Vitals\u3092\u6539\u5584\u3067\u304d\u308b\u3002<\/li>\n  <li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>\uff1a<code>npx astro add partytown<\/code> \u306e1\u30b3\u30de\u30f3\u30c9\u3067\u5b8c\u4e86\u3002\u305f\u3060\u3057 <code>forward: [\"dataLayer.push\"]<\/code> \u306e\u8ffd\u8a18\u3092\u5fd8\u308c\u305a\u306b\u3002<\/li>\n  <li><strong>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u4f5c\u6210<\/strong>\uff1ascript \u30bf\u30b0\u306b <code>type=\"text\/partytown\"<\/code> \u3092\u6307\u5b9a\u3059\u308b\u306e\u304c\u6700\u91cd\u8981\u3002\u3053\u308c\u304c\u306a\u3044\u3068Web\u30ef\u30fc\u30ab\u30fc\u3067\u52d5\u304b\u306a\u3044\u3002<\/li>\n  <li><strong>\u74b0\u5883\u5909\u6570<\/strong>\uff1a\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0ID\u306f <code>PUBLIC_GA_TRACKING_ID<\/code> \u3068\u3057\u3066 <code>.env<\/code> \u306b\u4fdd\u5b58\u3057\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u76f4\u66f8\u304d\u3057\u306a\u3044\u3002<\/li>\n  <li><strong>\u672c\u756a\u74b0\u5883\u306e\u307f\u8aad\u307f\u8fbc\u3080<\/strong>\uff1a<code>import.meta.env.PROD<\/code> \u3067\u672c\u756a\u30d3\u30eb\u30c9\u6642\u306e\u307fGA4\u3092\u8aad\u307f\u8fbc\u307f\u3001\u958b\u767a\u4e2d\u306e\u8a08\u6e2c\u30c7\u30fc\u30bf\u6df7\u5165\u3092\u9632\u3050\u3002<\/li>\n  <li><strong>\u52d5\u4f5c\u78ba\u8a8d<\/strong>\uff1a<code>npm run build &amp;&amp; npm run preview<\/code> \u3067\u30d3\u30eb\u30c9\u5f8c\u306b\u78ba\u8a8d\u3057\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bf\u30d6\u3067\u300cInitiator: partytown\u300d\u3068\u8868\u793a\u3055\u308c\u308c\u3070\u6210\u529f\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><span class=\"swl-marker mark_yellow\">Astro\u306bGA4\u3092Partytown\u3067\u5c0e\u5165\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u843d\u3068\u3055\u305a\u6b63\u78ba\u306a\u8a08\u6e2c\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u3001SEO\u3068UX\u306e\u4e21\u9762\u3067\u30b5\u30a4\u30c8\u306e\u54c1\u8cea\u3092\u9ad8\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059<\/span><\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WithCode\u3067\u5b66\u3093\u3060HTML\/CSS\/JavaScript\u306e\u57fa\u790e\u3092\u571f\u53f0\u306b\u3001Astro\u3067\u306e\u30b5\u30a4\u30c8\u5236\u4f5c\u3092\u59cb\u3081\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u7406\u89e3\u304c\u6df1\u307e\u308b\u307b\u3069\u3001Web\u30b5\u30a4\u30c8\u306e\u8cea\u3092\u9ad8\u3081\u308b\u624b\u6bb5\u304c\u5e83\u304c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">WithCode\u3092\u4f53\u9a13\u3067\u304d\u308b\u521d\u7d1a\u30b3\u30fc\u30b9\u516c\u958b\u4e2d\uff01<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u521d\u7d1a\u30b3\u30fc\u30b9\uff08\u00a549,800\uff09\u304c\u5b8c\u5168\u7121\u6599\u306b\uff01<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n  <li><strong>\u671f\u9593\uff1a<\/strong>1\u9031\u9593<\/li>\n  <li><strong>\u5b66\u7fd2\u5185\u5bb9\uff1a<\/strong>\u30ed\u30fc\u30c9\u30de\u30c3\u30d7\uff0f\u57fa\u790e\u77e5\u8b58\uff0f\u74b0\u5883\u69cb\u7bc9\uff0fHTML\uff0fCSS\uff0fJavaScript <strong><span class=\"swl-marker mark_yellow\">\u2192 Astro\u3084Partytown\u3092\u4f7f\u3044\u3053\u306a\u3059\u305f\u3081\u306e\u5fc5\u9808\u57fa\u790e\uff08HTML\u69cb\u9020\u30fbJS\u30fb\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u8003\u3048\u65b9\uff09\u3092\u4f53\u7cfb\u7684\u306b\u7fd2\u5f97\u3067\u304d\u308b\u30ab\u30ea\u30ad\u30e5\u30e9\u30e0\u3067\u3059<\/span><\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u526f\u696d\u30fb\u30d5\u30ea\u30fc\u30e9\u30f3\u30b9\u304c\u4e3b\u6d41\u306b\u306a\u3063\u3066\u3044\u308b\u4eca\u3053\u305d\u3001\u81ea\u3089\u306e\u30b9\u30ad\u30eb\u3067\u7a3c\u3052\u308b\u4eba\u6750\u3092\u76ee\u6307\u3057\u3066\u307f\u307e\u305b\u3093\u304b\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672a\u7d4c\u9a13\u3067\u3082\u5fc3\u914d\u3059\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u521d\u7d1a\u30b3\u30fc\u30b9\u3092\u53d7\u8b1b\u3055\u308c\u308b\u65b9\u306e\u5927\u591a\u6570\u306f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u672a\u7d4c\u9a13\u3067\u3059\u3002\u307e\u305a\u306f\u7121\u6599\u30ab\u30a6\u30f3\u30bb\u30ea\u30f3\u30b0\u3067\u3001\u60a9\u307f\u3084\u4e0d\u5b89\u3092\u304a\u805e\u304b\u305b\u304f\u3060\u3055\u3044\uff01<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/withcode.tech\/reservation\/\" style=\"background-color:#ffbf00\"><strong>\u516c\u5f0f\u30b5\u30a4\u30c8\u304b\u3089\u7121\u6599\u30ab\u30a6\u30f3\u30bb\u30ea\u30f3\u30b0\u306b\u7533\u3057\u8fbc\u3080 \u2192<\/strong><\/a><\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Astro\u306bGA4\u3092Partytown\u3067\u5c0e\u5165\u3059\u308b4\u30b9\u30c6\u30c3\u30d7\u3092\u5b8c\u5168\u89e3\u8aac\u3002npx astro add partytown \u304b\u3089forward\u8a2d\u5b9a\u30fbGoogleAnalytics.astro\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5b9f\u88c5\u30b3\u30fc\u30c9\u30fbimport.meta.env.PROD\u3067\u672c\u756a\u74b0\u5883\u306e\u307f\u8a08\u6e2c\u3059\u308b\u65b9\u6cd5\u30fbTBT\u524a\u6e1b\u306e\u78ba\u8a8d\u624b\u9806\u307e\u3067\u7db2\u7f85\u3057\u305f2026\u5e74\u6700\u65b0\u30ac\u30a4\u30c9\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"swell_btn_cv_data":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":"0"},"categories":[34,359],"tags":[],"class_list":["post-13074","post","type-post","status-publish","format-standard","hentry","category-programming","category-javascript-programming"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/13074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/comments?post=13074"}],"version-history":[{"count":2,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/13074\/revisions"}],"predecessor-version":[{"id":14020,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/13074\/revisions\/14020"}],"wp:attachment":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/media?parent=13074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/categories?post=13074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/tags?post=13074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}