下記は、第3回セミナーのイベント「purchase」で使用したデータレイヤーです。
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "100-02",
affiliation: "GA4 Quick",
value: 10000,
tax: 1000,
shipping: 500,
currency: "JPY",
coupon: "2022_SPRING_SEMINAR",
items: [{
item_name: "2022_SPRING_SEMINAR_04",
item_id: "22ss04",
price: 10000,
item_brand: "and,a",
item_category: "Online_Seminar",
item_variant: "ZOOM",
quantity: 1
}]
}
});
</script>
上記の2行目、
window.dataLayer = window.dataLayer || [];
について解説します。
dataLayerはJavaScriptで「配列」と呼ばれるものになります。
「配列」は中にいろいろな要素をリスト形式で保有することができるもので、
そして「配列」はその要素を追加・削除・検索など行うことが可能です。
dataLayerは「継ぎ足し継ぎ足ししていく」のが本来的な使い方です。
window.dataLayer = window.dataLayer || [];
は、「dataLayerという名前で配列を新規作成する」というものになります。
GTMはページ上にdataLayerという配列が存在したらそちらを利用する形です。
(存在しない場合はGTMが勝手に作成します)
そして、dataLayer.push()
というのは上で触れた「配列に要素を追加する」ものとなり、()
の中身をdataLayerに追加する、という文法になっています。
これによって、「作成した配列に対してpurchase用のデータを追加する」形になります。
これが「継ぎ足し継ぎ足し」できる、という意味になります。追加されるデータに関して、「{ }
で囲んだ範囲」はご存知かと思いますが、「event」パラメータに関しては「データの第一階層に配置する必要がある」形です。
I really liked your article.Really thank you! Fantastic.
I really liked your article post.Really looking forward to read more. Awesome.
Im grateful for the blog article.Really thank you! Want more.
Fantastic article post. Will read on…
Awesome post.Much thanks again. Much obliged.
Fantastic blog.Much thanks again. Fantastic.
This is one awesome article.Really looking forward to read more. Really Cool.
Thanks a lot for the blog post. Fantastic.
Hey, thanks for the article post.Really looking forward to read more. Keep writing.
I really enjoy the blog article. Want more.
A big thank you for your blog.Thanks Again. Want more.
Thanks so much for the blog article.Much thanks again. Awesome.
Very neat article.Much thanks again. Much obliged.
I really enjoy the article post.Thanks Again. Much obliged.
Great, thanks for sharing this article post.Really thank you! Much obliged.
Great, thanks for sharing this article post.Really thank you! Cool.
wow, awesome article.Thanks Again. Much obliged.
Greate article. Keep writing such kind of info on your page.
Im really impressed by it.
Hey there, You have done an excellent job.
I’ll certainly digg it and for my part recommend
to my friends. I am confident they will be benefited
from this site.
Wonderful beat ! I would like to apprentice while you amend your website, how
can i subscribe for a weblog website? The account helped me a applicable deal.
I have been tiny bit familiar of this your broadcast offered bright transparent idea
Hi there, after reading this amazing piece of writing i am
too happy to share my knowledge here with colleagues.
Hello, this weekend is nice in support of
me, for the reason that this time i am reading this impressive informative paragraph here at my home.
Also visit my page … vpn special code
I’m truly enjoying the design and layout of your website.
It’s a very easy on the eyes which makes it much more enjoyable for me to
come here and visit more often. Did you hire out a designer to
create your theme? Great work!
My homepage – vpn coupon 2024
After I originally left a comment I appear to have clicked
on the -Notify me when new comments are added- checkbox and from
now on each time a comment is added I get 4 emails with the same comment.
Is there a means you are able to remove me from that service?
Thanks!
Wow, that’s what I was exploring for, what a stuff!
existing here at this web site, thanks admin of this web page.
I truly appreciate this blog article.Thanks Again. Really Great.
Very neat blog post.Much thanks again. Will read on…