Hello,
As you all know, now Google usually generates an AI result for any search, giving you the sources it used on the right. If you click on those, it will take you to your site URL appending something like "#:~:text" to it.
I have created a Marketing Channel to allocate traffic coming from sites like Chat GPT and so to "AI traffic", and I want to send these AI generated results to this bucket. The problem is that I don't know how to capture this "#:~:text=" used by Google. Neither window.location.hash nor window.location.href worked :s.
Any ideas? I would also appreciate if you shared any other tips regarding the use of AI as a Marketing Channel.
Thanks!
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
I was just posting about this in another thread... for some reason this newer hash version doesn't seem to be extractable....
If I have a normal hash (#something), I can use window.location.hash to get the hash value
However, if I do this on this newer "scroll to text" hash, the above doesn't work....
I've tried multiple attempts, and all have failed.
Views
Replies
Total Likes
Thanks for the effort! Any workarounds on this AI attribution? As obviously, we have to take this new AI channels into consideration.
Views
Replies
Total Likes
I believe that is more focused on "traditional" AI sites like ChatGPT.. but I guess we will see.
Google really hasn't done anyone any favours to identifying their AI results..
Views
Replies
Total Likes
The #:~:text fragment that Google appends is part of the Scroll-to-Text Fragment API
Unlike standard URL hashes, it isn’t exposed through window.location.hash for privacy and security reasons, which is why you’re not able to capture it directly in JavaScript.
If your goal is to track visits coming from Google AI-generated results, a more reliable approach is to key off the referrer (Google domains) combined with the presence of the fragment pattern in the landing URL captured server-side (since some servers log the full request including fragments). If server logs don’t give you access to it, you may need to rely on referrer plus other identifiers, rather than trying to parse the fragment on the client.
At the moment, there isn’t a client-side workaround that will expose the #:~:text portion.
Views
Replies
Total Likes
Wouldn't it work with an approach like this? https://www.owntag.eu/blog/scroll-to-text-fragments-in-ga4/ It seems to be working on GA4...
function test() { if (performance && performance.getEntries()[0].name.indexOf("#:~:text=") != -1) { var entries = decodeURIComponent(performance.getEntries()[0].name.match("#:~:text=(.*)")[1]); var frag = entries.replace(/, /g,"*").replace(/,/g,"...").replace(/\*/g,", "); return frag; } else return ""}
Ah good catch, I didn't realize that Scroll To Text Fragments were available in the performance object.
However, there is still nothing that prevents other, non-AI systems from using this type of fragment notation. Scroll to Text is just that, a way to scroll to a position on a page where specific text appears... this isn't limited to AI Mode.
I would be tempted to merge this with a referral check (making sure that this is only coming from Google, or other known AI sources that use this type of fragment - to avoid potential inflation)
It will be interesting to see if Adobe has built this logic into their new AI Referrer Type...
But definitely something to play with, thanks @mjdavid007
Views
Replies
Total Likes
Oh, no need to thank me, I got it from the blog I posted :p. If you shared how to proceed from there (I'm not an expert) I would appreciate it. And yes, this+referral should work for sure :). Also, although this doesnt prevent anybody from using this scroll to text, it's not very likely to happen, at least on our company.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies