※この記事には、修正版がございます。下記の方法でも動作は致しますが、設定についても、挙動についても、より効率的な方法がありますので、こちらの修正版の記事をご参照ください。
この記事では、URLの特定の位置にある文字列を取り出して、GA4のイベントのパラメータとして取得する方法を説明します。
今回の与件は、URLの例として、
https://ga4-quick.and-aaa.com/gtm-test/venezia/20220826/
というURL中の文字列(今回の場合は「/gtm-test/文字列/20220826/」)を取得して、イベントパメータに入れる方法を解説します。
URL から情報を取得
まずは情報を取得したいページ(商品ページなど)をユーザーが閲覧したときに、URL から 文字列 を取得する設定を行います。
ここでは URL から取得したい 文字列 を変数「textdata」として取得し、それをイベントのパラメータで使用できる形に格納します。
タグから新規タグを作成し、「カスタム HTML」を選択します。
今回の URL の場合は、HTML 部分に下記を記載します。
<script>
var textdata = '';
textdata = window.location.pathname.split('gtm-test/')[1].split('/')[0];
dataLayer.push({
'get_from_url': window.textdata,
'event': 'get_url_text'
});
</script>
URL から情報を取得した時に行ったことを順を追って説明していきます。
まず「var textdata = ”;」で取得したい ID を定義します。この「textdata」は任意の文字列で大丈夫です。
次に URL からデータを取得します。
「window.location.pathname」で URL のパスを取得します。パスとはドメイン以下、今回の場合は「/gtm-test/文字列/20220826/」です。
今回はパスの取得なので「.location.pathname」を使用しましたが、たとえば URL 全体を取得したい場合は「location.href」、パラメータ部分(?以降)を取得したい場合には「location.search」を使用します。
次に「/gtm-test/文字列/20220826/」の「文字列」部分のみを残すためにデータの加工をおこないます。「.split」で文字列を任意の場所で切り、その前([0])か後ろ([1])かを残すことができます。
今回の場合は「/gtm-test/」と「文字列」の後の「/」を除きたいので、.split(‘gtm-test/’)[1].split(‘/’)[0]と設定しました。
ここまでで URL からの取得とデータの加工は完了です。
次に GTM にデータを送信するため、下記のように記載します。
dataLayer.push({
'get_from_url': window.textdata,
'event': 'get_url_text'
});
ここでは先ほど取得した変数 textdata をイベントのパラメータで使う「get_from_url」に入れ込みます。
イベントの設定(’event’: ‘get_url_text’)は、後で行います。
このイベントのトリガーは、下記のように設定しておきます。
ということで、このようなイベントになりました。
変数の設定
上記で取得した情報(textdata)をタグで使用できるようにするために、変数の設定をします。
「変数」から「ユーザー定義変数」の新規を選択し、変数タイプの「データレイヤーの変数」を選択します。
「データレイヤーの変数名」に先ほど作成した「get_from_url」と入力し、変数名も同じ「get_from_url」に設定したら変数の設定は完了です。
タグとトリガーの設定
次に、URLから取得した文字列をGA4に送信するイベントタグを設定します。
イベント名は、前出の’event’: ‘get_url_text’のところで決めてあったので、それを入力します。
イベントパラメータのパラメータ名で、「データレイヤーの変数名」として先程設定した、「get_from_url」を入力します。
これで、URLから取得した文字列をGA4に送信するイベントタグの設定ができました。
ここまで出来たら、タグを「公開」してください。
文字列取得の確認
DebugViewにて、文字列の取得が確認できたら成功です。
質問なのですが、こちら正規表現の表やカスタムJavascriptではなくデータレイヤー変数を用いるのはなぜでしょうか? 変数で取得すればConfigタグでも設定できるようになるので便利かなと思っております。
性能面で優位ということであればどれほど差が出るのかご教示いただきたいです。
貴重なご指摘をいただきまして、ありがとうございます。
ご指摘いただきました通りで、上記の実装方法には、優位性はございません。
修正版の記事を作成させていただきました。
https://ga4-quick.and-aaa.com/archives/2892
今後とも、よろしくお願い申し上げます。
Im obliged for the post. Keep writing.
Very neat blog.Thanks Again. Really Great.
Really appreciate you sharing this post. Keep writing.
Really enjoyed this post. Fantastic.
I really like and appreciate your blog.Really thank you! Fantastic.
Thanks so much for the article post.Thanks Again. Really Great.
Really informative post. Fantastic.
Major thanks for the blog article.Thanks Again. Really Cool.
Really enjoyed this blog article.Really thank you! Fantastic.
Thanks again for the article post.Much thanks again. Great.
A big thank you for your blog.Really looking forward to read more. Keep writing.
I really enjoy the blog article.Thanks Again. Really Cool.
A big thank you for your post.Thanks Again. Cool.
I think this is a real great post.Really thank you! Awesome.
Thanks so much for the post.Much thanks again. Fantastic.
Im thankful for the blog.Really thank you! Great.
Hey there! I know this is kinda off topic but I’d figured I’d ask.
Would you be interested in exchanging links or maybe guest
authoring a blog post or vice-versa? My site addresses a lot of the
same topics as yours and I feel we could greatly benefit from each other.
If you’re interested feel free to shoot me an email.
I look forward to hearing from you! Awesome blog by the way!
I just like the valuable information you supply on your articles.
I will bookmark your weblog and take a look at again right here regularly.
I am slightly certain I’ll be informed a lot of new stuff right here!
Good luck for the next!
Hello to all, as I am in fact keen of reading this blog’s
post to be updated on a regular basis. It carries pleasant data.
Hey would you mind letting me know which hosting company you’re utilizing?
I’ve loaded your blog in 3 completely different browsers
and I must say this blog loads a lot quicker then most.
Can you suggest a good internet hosting provider at a honest price?
Thanks a lot, I appreciate it!
Hey, thanks for the article.Really looking forward to read more.
It’s an amazing article for all the internet users; they will take benefit from it I am sure.
This is the right webpage for anyone who hopes
to find out about this topic. You understand so much its almost tough
to argue with you (not that I really will need to…HaHa). You definitely
put a fresh spin on a subject that’s been written about for
decades. Wonderful stuff, just great!
farmaci a prezzo competitivo a Roma Fannin Bollate médicaments disponible au
Québec
medicamentos sin receta en México Biofarma Santa Cruz de Tenerife Pedir medicamentos en línea sin receta
farmaci in vendita in Belgio senza ricetta Polpharma Ixtapaluca médicaments en pharmacie en ligne française
médicaments : Avantages et précautions à connaître SMB Alzira–Xàtiva Options d’expédition discrète
pour le médicaments en Belgique
farmaci autentico senza prescrizione medica in Belgio teva Nieuwegein médicaments recommandé par des experts
Medikamente rezeptfrei online bestellen Kern Beverwijk Wie nehme ich Medikamente ein?
бақ-тың атқаратын маңызды қызметтері, бақ мақсаты шешендік сөздің түрлері,
шешендік сөздер кітабы 3ds max
деген не, autodesk 123d tinkercad деген не
территориальное выравнивание это, предложите идеи по
усилению связей казахстана
с другими странами
commander des comprimés en ligne sans ordonnance Pharmachemie Meyrin medicamentos bajo prescripción médica
как род влияет на деньги, родология лженаука диваны алматы цены, белорусские диваны в алматы ұлы жібек жолының қызмет ете
бастаған уақыты, ұлы жібек жолының қарқының әлсіреткен жағдайлар тырнаға ұқсайтын құс, мойны сұрақ белгісі
бұл қандай көл құсы
Thanks for finally writing about > 【GA4】 URLから文字列を取得して、イベントパラメータに入れる – GA4 Quick.com < Liked it!
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
игликов амангельды нугманов
нотариус, игликов амангельды
нугманович толстой после бала распечатать,
сердце матери сокпакбаев слушать онлайн тау бұлағы да
ағады, ғасырлар перзенті когда
была провозглашена автономия казахских областей алаш-орда?, партия алаш тесты с ответами
Hey there! Do you know if they make any plugins to help
with SEO? I’m trying to get my site to rank for some targeted keywords but I’m
not seeing very good results. If you know of any please share.
Cheers! You can read similar blog here: Eco product
Egypt is a whole tourist country and it is best to make some extent to get off the beaten path a little bit bit.
Good
sugar defender ingredients Uncovering Sugar Defender has actually
been a game-changer for me, as I’ve constantly been vigilant about managing my blood sugar level levels.
I now really feel encouraged and confident in my capability to keep
healthy and balanced levels, and my newest checkup have actually mirrored this progress.
Having a trustworthy supplement to match my a significant source of convenience,
and I’m absolutely happy for the substantial distinction Sugar
Defender has actually made in my general well-being.
I would like to thank you for the efforts you have put in penning this blog. I really hope to check out the same high-grade content from you in the future as well. In fact, your creative writing abilities has motivated me to get my own, personal blog now 😉
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
I couldn’t refrain from commenting. Perfectly written.
Good post. I absolutely love this website. Keep it up!
Oh my goodness! Awesome article dude! Thanks, However I am going through problems with your RSS. I don’t understand the reason why I cannot join it. Is there anybody having the same RSS issues? Anyone that knows the answer can you kindly respond? Thanx.
Terlincthun British Cemetery is located high on the cliffs of Boulogne, from which it is sometimes doable to see the white cliffs of the English coast.
Excellent blog post. I definitely appreciate this site. Stick with it!
As portrayed in all Star Wars-associated media, the dark aspect gives customers with powers much like those of the light side-using Jedi, but as it leverages passion and violence, its use is enhanced by unfavorable uncooked and aggressive feelings and instinctual feelings reminiscent of anger, greed, hatred, and rage.
The plates usually are not subject to renewal necessities by the Louisiana Division of Public Safety, and they’re issued upon utility to any former Prisoner-of-Conflict in lieu of the common motor vehicle registration license plates.
The adapters are additionally emulated in a number of the C64 emulators.
Spot on with this write-up, I absolutely believe this web site needs a great deal more attention. I’ll probably be back again to see more, thanks for the info!
I would like to thank you for the efforts you’ve put in writing this site. I am hoping to view the same high-grade blog posts by you in the future as well. In truth, your creative writing abilities has motivated me to get my own, personal blog now 😉
After exploring a few of the blog articles on your web page, I honestly appreciate your technique of writing a blog. I added it to my bookmark webpage list and will be checking back soon. Please visit my web site too and let me know how you feel.
Good post. I’m experiencing some of these issues as well..
Oh my goodness! Amazing article dude! Thank you so much, However I am having difficulties with your RSS. I don’t know the reason why I am unable to join it. Is there anybody else having similar RSS issues? Anyone who knows the answer can you kindly respond? Thanks.
This is the right blog for anyone who hopes to find out about this topic. You understand so much its almost tough to argue with you (not that I really will need to…HaHa). You definitely put a brand new spin on a subject that has been discussed for ages. Great stuff, just excellent.
Fareportal operates in North America, Europe, and Asia and they’ve partnered with over 500 airlines, over 1 million hotels, and a whole lot of automotive businesses everywhere in the world.
Great blog you have got here.. It’s difficult to find excellent writing like yours these days. I seriously appreciate people like you! Take care!!
Satisfying his social ambitions for the medium, he enclosed the previous Victorian spa in a barrel-vaulted skin of stained glass, bathing the general public area “in an immense blue light”.
Pretty! This has been an incredibly wonderful post. Many thanks for providing this info.
The participant named first played the white items.
An impressive share! I’ve just forwarded this onto a colleague who had been conducting a little research on this. And he in fact ordered me dinner because I discovered it for him… lol. So allow me to reword this…. Thank YOU for the meal!! But yeah, thanx for spending some time to discuss this topic here on your web page.
Low Degree Foxes: Are the Foxes who aren’t capable of controlling themselves.
I absolutely love your site.. Excellent colors & theme. Did you make this website yourself? Please reply back as I’m hoping to create my own website and would like to find out where you got this from or just what the theme is called. Cheers!
Good day! I just wish to give you a big thumbs up for your excellent info you’ve got right here on this post. I’ll be coming back to your web site for more soon.
I really like reading a post that will make people think. Also, thanks for permitting me to comment.
After study a handful of the web sites on your own site now, we truly appreciate your way of blogging. I bookmarked it to my bookmark website list and you will be checking back soon. Pls take a look at my internet site in addition and inform me what you believe.
She married David F. Nickles and had two daughters, Mrs.
After I initially commented I seem to have clicked on the -Notify me when new comments are added- checkbox and now every time a comment is added I recieve four emails with the same comment. There has to be a way you can remove me from that service? Kudos.
After exploring a few of the blog articles on your website, I really like your technique of writing a blog. I book marked it to my bookmark website list and will be checking back in the near future. Take a look at my web site as well and let me know what you think.
I admit, I have not been on this blog in a long time, however it was joy to find it again. It is such an important topic and ignored by so many, even professionals! I thank you for helping to make people more aware of these issues. Just great stuff as per usual!
Wohh exactly what I was looking for, appreciate it for posting .
I blog quite often and I truly appreciate your content. This great article has really peaked my interest. I’m going to take a note of your blog and keep checking for new information about once a week. I opted in for your Feed as well.
This web site is usually a walk-through its the information you wished about this and didn’t know who ought to. Glimpse here, and you’ll definitely discover it.
Excellent site you have here.. It’s difficult to find high quality writing like yours these days. I honestly appreciate people like you! Take care!!
This is a topic that’s close to my heart… Take care! Where can I find the contact details for questions?
Everything is very open with a clear clarification of the issues. It was truly informative. Your site is very helpful. Thank you for sharing.
It?s actually a cool and helpful piece of information. I am glad that you shared this useful info with us. Please keep us up to date like this. Thanks for sharing.
I want to point out my gratitude for your kindness for visitors who need assistance with in this study. Your personal dedication to passing the solution throughout came to be extremely insightful and has in most cases permitted associates just like me to reach their pursuits. Your personal insightful publication signifies so much a person like me and even more to my mates. Warm regards; from each one of us.
sports jerseys that uses cotton and polyester fabric are much cooler to use**
I like it whenever people get together and share ideas. Great website, keep it up.
Prior to you decide to create your own checklist to include an idea associated with what camping checklist ought to. Really … A listing can be greater than what you need.
Nice post. I find out some thing tougher on various blogs everyday. Most commonly it is stimulating to learn to read content from other writers and exercise a specific thing at their store. I’d would prefer to apply certain while using the content on my own blog whether or not you don’t mind. Natually I’ll supply you with a link on your own internet blog. Thank you for sharing.
It’s super site, I was looking for something like this
I love to visit your web-blog, the themes are nice.;,’-’
I think other site proprietors should take this website as an model – very clean and magnificent style and design, as well as the content. You are an expert in this area!
Good post. I learn something new and challenging on blogs I stumbleupon on a daily basis. It’s always exciting to read content from other writers and practice something from their websites.
Votre paragraphe : plusieurs satisfaisants sujets de discussion néanmoins je me méfie de la fidélité de la plupart des valeurs parus là dans cet ultime post
I could not resist commenting. Perfectly written.
I?ve been exploring for a little bit for any high-quality articles or blog posts in this kind of area . Exploring in Yahoo I at last stumbled upon this website. Reading this info So i?m happy to exhibit that I have a very good uncanny feeling I discovered exactly what I needed. I such a lot indubitably will make sure to don?t forget this web site and provides it a look a relentless basis.
The only words I know is * I ain’t got nothing but some p*ssy &some paper* lol|im_SarahLee|
Very good information. Lucky me I came across your blog by chance (stumbleupon). I have saved as a favorite for later!
Appreciate this excellent article. I especially enjoyed reviewing it and ought to discuss it with everyone.
A lot of thanks for all your hard work on this site. My niece really likes getting into investigation and it’s easy to understand why. My partner and i learn all regarding the compelling tactic you present invaluable things via the web site and therefore attract participation from others about this article so my simple princess is always starting to learn a great deal. Take advantage of the remaining portion of the new year. Your conducting a really good job.
I do accept as true with all the ideas you have introduced in your post. They’re really convincing and can definitely work. Nonetheless, the posts are very short for novices. May you please extend them a bit from subsequent time? Thank you for the post. Commission Siphon Review
I couldn’t resist commenting. Well written!
This blog was… how do I say it? Relevant!! Finally I’ve found something which helped me. Appreciate it.
I feel like I’m often looking for interesting things to read about a variety of niches, but I manage to include your blog among my reads every day because you have compelling entries that I look forward to. Here’s hoping there’s a lot more amazing material coming!
I came across your blog’s link posted by a friend of mine on Facebook. Thanks for putting useful info on the internet. It’s tough to get these things these days.
This article weighs in as a heavy weight hitter in my opinion. The content is informative, but it’s also clear. This is right on point as far as I’m concerned.
Intimately, the article is in reality the freshest on that valuable topic. I fit in with your conclusions and definitely will eagerly look forward to your coming updates. Simply just saying thanks will not just be acceptable, for the extraordinary lucidity in your writing. I will certainly ideal away grab your rss feed to stay abreast of any updates. De lightful work and also much success in your business endeavors!
A well written article, I just passed this onto a workfellow who was doing somewhat analysis on this. And he indeed purchased me dinner because I discovered it for him…. .. therefore let me reword that: Thnkx for the treat however yeah Thnkx for spending the time to talk about this, I feel strongly concerning it and love reading more on this topic. If doable, as you gain expertise, would you mind updating your blog with more details? it is extraordinarily useful on behalf of me. massive thumb up for this blog
Wow! This could be one particular of the most helpful blogs We’ve ever arrive across on this subject. Basically Excellent. I’m also an expert in this topic therefore I can understand your effort.
It’s a shame you don’t have a donate button! I’d certainly donate to this excellent blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will talk about this site with my Facebook group. Chat soon!
Great article mate, keep the great work, just shared this with ma friendz
Hello there, I discovered your website by way of Google whilst searching for a related matter, your website got here up, it looks good. I’ve bookmarked it in my google bookmarks.
Right here is the perfect blog for anyone who would like to understand this topic. You understand so much its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a new spin on a topic that has been written about for years. Wonderful stuff, just excellent.
Once you select a venue, then our creative marriage ceremony decorators work collectively to boost the great thing about venue with essentially the most beautiful decoration.
He was introduced within the second season of Star Wars Rebels, the place he and the Seventh Sister were tasked with searching the Ghost crew after the Grand Inquisitor’s dying, during which in addition they competed in opposition to one another to develop into the subsequent Grand Inquisitor.
Both the Vichy French Navy and Free French Navy fought the Battle of the Mediterranean sea.
This is the perfect web site for anyone who would like to understand this topic. You know a whole lot its almost hard to argue with you (not that I actually will need to…HaHa). You certainly put a new spin on a subject which has been discussed for decades. Wonderful stuff, just wonderful.
Heya i am for the first time here. I found this board and I find It really useful & it helped me out much. I hope to give something back and aid others like you helped me.
Hello! I simply would like to give you a large thumbs up with the great information you could have here on this post. I’ll be returning to your site to get more detailed soon.
Youre so cool! I dont suppose Ive read anything in this way just before. So nice to get somebody with a few original thoughts on this subject. realy appreciation for beginning this up. this web site is something that is needed on the net, a person with some originality. helpful problem for bringing a new challenge towards web!
One of the moreimpressive blogs I’ve read. Thanks so much for keeping the internet classy for a change. You’ve got style. I mean it. Please keep it up because without thenet is definitely lacking in intelligence.
Very nice design and style and fantastic subject matter, very little else we want : D.
Wonderful post! We are linking to this great post on our website. Keep up the great writing.
Im no expert, but I consider you just made the best point. You naturally know what youre speaking about, and I can really get behind that. Thanks for being so upfront and so sincere.
I have to say that this is really a good influencing look at this particular subject matter. I’m really pleased you shared your thoughts plus smart ideas and I discovered I somewhat agree. I seriously like your clear writing additionally , the efforts you might have used writing this submit. Numerous thanks yous for your strong work and very good luck with your blog, I most certainly will be awaiting new articles within the future.
Excellent web site. Lots of useful info here. I’m sending it to some friends ans also sharing in delicious. And obviously, thanks for your effort!
Whats up, I’m ranking my site higher “pre spun articles”.
I was more than happy to find this website. I want to to thank you for ones time for this fantastic read!! I definitely loved every bit of it and i also have you saved as a favorite to look at new information in your web site.
Make sure you excuse my my English speak, i’m simply schooling. I very much like your web site greatly, I realize it quite fascinating and that i saved a bookmark in my personal web.
Fotbollsresor Arsenal ( Football Journey Arsenal ) is one of the vital practised game based tour throughout the world.
Very nice blog post. I absolutely love this site. Continue the good work!
You are so awesome! I don’t believe I’ve truly read through anything like that before. So good to find someone with some unique thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the web, someone with some originality.
A View of the Delaware from Bordentown Hill by Charles B. Lawrence Archived 2006-05-28 on the Wayback Machine, New Jersey Historic Society.
I really like reading an article that will make men and women think. Also, many thanks for allowing me to comment.
Greatful to found this blog, I have been looking many times about it. This is actually what I have been seeking and I’ve bookmarked this web site also, I will be back again soon to look at for your new posting.
There are undoubtedly a lot of specifics like that to think about. That is a good point to raise up. I supply the thoughts previously mentioned as normal inspiration however clearly you can find questions like the one anyone bring up the spot that the most important thing will be working in honest good faith. My spouse and i don?testosterone levels know if guidelines have emerged around such thinggs as that, nonetheless I am sure that a job will be clearly known as a fair game. Both kids feel the affect of just a moment’s delight, for the rest of their particular lives.
Spot up with this write-up, I seriously think this amazing site needs additional consideration. I’ll probably be once more to read much more, many thanks that information.
After going over a few of the blog articles on your web page, I honestly like your way of blogging. I bookmarked it to my bookmark webpage list and will be checking back soon. Please visit my web site as well and tell me your opinion.
Can you please email me the info on how you designed your homepage? Did you do that with a template or is it custom? I stink at this stuff, but it looks great!
Some really great articles on this site, appreciate it for contribution.
Audio began playing when I opened up this web site, so annoying!
You made some really good points there. I checked on the web to find out more about the issue and found most individuals will go along with your views on this web site.
Everyone loves it when individuals get together and share thoughts. Great website, stick with it!
Spot on with this write-up, I actually feel this site needs far more attention. I’ll probably be back again to read more, thanks for the advice!
After going over a handful of the blog articles on your website, I seriously appreciate your technique of blogging. I book marked it to my bookmark webpage list and will be checking back in the near future. Take a look at my web site as well and let me know your opinion.
Sometimes, blogging is a bit tiresome specially if you need to update more topics.:,-;”
This site is my aspiration , real superb pattern and perfect subject matter.
I’m extremely pleased to find this page. I want to to thank you for ones time due to this fantastic read!! I definitely savored every bit of it and I have you saved to fav to look at new information on your website.
I believe one of your advertisings triggered my internet browser to resize, you may well want to put that on your blacklist.