Google analytics iframe tracking - iframe

I'm looking to track iframe and the content/destination url in the iframe. But the requirement is GA Event tracking generated from iframe inherits the page level dimensions &metrics set by page view and looking to pass same cookie value from parent iframe. Can anyone help on this.

Related

Setup cross-domain tracking for iframe

I want to attribute the purchase event and other events made inside an iframe to the source from where the user came from (Ads/UTM) on the parent page.
According to Google (Link below: Manual setup Method), if I initialize Google Analytics 4 (ga4) inside the iframe with the same client_id and session_id as the parent page, it will be considered the same user.
However, when I try this, a new user and session are being created even though the cookie values for _ga and ga are the same for both the parent and the iframe. I have confirmed that these cookie values are the same.
https://support.google.com/analytics/answer/10071811?hl=en#zippy=%2Cmanual-setup
Is there something I am missing or doing wrong?

Fire a page view tag but only if it was from a specific referral URL. Google tag manager

I have a form that when submitted it goes to a different "success page" and I want to use that landing page to track conversions or count how many times people hit the "submit". I could use a page view tag but then that will fire every time someone goes to that page. So perhaps if someone hits the back button and reloads the page then that will count as a form submit.
So I would like to make a page view Tag in google tag manager that only fires if the page view is coming from a specific URL or referred from a specific URL. Is this possible?
Thanks in advance.
It is possible. Enable the built-in "referrer" variable, and on your target page create a trigger "pageview", with an added condition "referrer equals <your referrer>".
Some browsers might not send a referrer header, so this is not 100% reliable. If the page that sends the traffic is under your control, you might consider using a tracking parameter instead.

Iframe and parent page both being tracked by GA

We have a page used for ads that feature an iframe of a form (all on the same domain). The page and the iframe are both being tracked in analytics, but we only want the main page to be tracked. Our analytics are not accurate due to this and I am trying to turn off tracking for the iframe page. I just want the parent page to be tracked and not the page that is in an iframe on the parent page.
Have tried setting up a filter on GA but that had the opposite effect we needed.
A possible solution would be to check if the current page sits in an iframe and, if so, use an exception trigger on your Google Analytics tags.
E.g. you could create a custom javascript variable "isIframe":
function() {
return window.location !== window.parent.location;
}
If this returns true, you are inside the iframe.
Then you create trigger of the "custom event" type, enable regex matching and put in ".*" in the event name (so this catches all events). Select "fires on some events" and set "isIframe equals true" as condition. Attach this as an exception trigger to your GA tracking tag(s).
Now if your GTM instance runs inside the iframe the tracking is blocked (so the iframe will not be counted as a pageview), but the tracking for the host page will still work.

Creating GTM trigger/Linkedin Pixel tag for Drift chat click

I need to add a LinkedIn pixel to GTM to track Drift chat widget being clicked.
I have already added the LinkedIn pixel to a GTM tag, I know I did that correct. I created a GTM trigger that is set with the GTM tag and I'm having problems with the GTM tag not triggering. I have tried:
Trigger Configuration -> Trigger Type -> Click - All Elements
This trigger fires on -> Some Clicks -> Fire this trigger when an Event occurs and all of these conditions are true -> Click Classes -> equals -> [some class names I see when inspecting element]
The widget is placed inside an iframe. Should I assume any attempts to capture clicks from elements in the iframe will fail? When I "Preview" in GTM, view our site with the Tag Manager window open and then click the Drift chatbot widget - the GTM tag I created doesn't fire.
You won't get events from the iframe by default.
the iframe is a separate, complete HTML page. If this is a third party widget, then it sounds like a safe bet that your GTM code is not embedded into that page, so you can catch events via the native GTM functions.
as a third widget this runs most probably not on the same domain as your page. Cross-Domain communications with iframes is not something that happens by default (that's a security feature). If you can place Javascript into your widget, then you can communicate with your main page via window.postMessage (but then if you can place code you might be able to embed your GTM instance).
If Drift has something like tech support I would suggest to contact them - this is such a common issue that it's quite probable that they will have a solution ft it.

GA not displaying pageView dataLayer event

For some reason Google Analytics only shows the current active page on refresh. Not if I click through the site without refreshing.
If I inspect my website using Google Tagmanager preview I can see the dataLayer push, however it is not visible in Google Analytics..
image from dataLayer
image from GA tag added to GTM
Anyone know what the problem could be?
In you tag you are using the trigger 'all pages',this obey to the dataLayer {'event':'gtm.js'} while i see that you are pushing {'event' : 'Page View'}. If you see the debugger in both case you will see the Pageview as out put, but on the back, they are 2 differents things
The solution is to create a new trigger that obey to the event 'Page View' and use both triggers.
Greetings

Resources