Google Tag Manager: fire tag on element load - google-tag-manager

I am working on a project and the site has a lot of the same pages - they are versions of the homepage. But, depending on what page you open, it will give you a different message in a lightbox.
The whole set-up is a bit strange to me, but that's what it is....
So there are countless pages, such as "~/erejib", "~/12312", "~123niwoenf123". Due to there being no fixed length, naming convention or anything, I cannot really use a regex.
However, I could say fire on all pages that contain this lightbox ID. Does Google Tag Manager support this at all?
Thanks,
Chris

Well yes, there is nothing build into Google Tag manager for this particular problem. I ended up writing all the existing pages that I want to exclude into a giant RegEx.

Related

How to get the XPATH or CSS selector from dynamically loaded website to follow links?

This is a dynamically-loaded website https://www.gelbeseiten.de/suche/hotels/n%c3%bcrnberg.
I'm trying to follow every link from the results. I found //article[#class='mod mod-Treffer']/a to follow the search result links. But the problem is this XPATH works only for a couple of links. For the rest of the others, I don't find any Selector. Because the other are using probably JS to make this action. I'm not familiar with this kind of dynamic website. So, I don't know how to get the selector from this kind of website. Any suggestions will be highly appreciated.
I will post this as an answer, without actually giving you the code, as it might help you more in the long term.
First, load that page in browser with javascript disabled (there are ways with disabling js in browser directly, or use an extension like ublock origin, etc - look it up).
You will notice that only the first 2 hotels are fully loading - the rest are being loaded dynamically by javascript (which in this case is disabled). There are 13 hits for //article[#class='mod mod-Treffer']/a selector, while there are more hotels on that page.
However, each hotel is wrapped in an <article> tag, and that tag has data-realid="[...]" attribute. The url for each hotel would be https://www.gelbeseiten.de/gsbiz/{data-realid}.
This is how you can get all those hotels' profile links.

Google Analytics implementation problems

I am trying to implement GA to track traffic to a Medium page. First of all I don´t know and I couldn´t found if this is trackable at all since I don´t really "own" this url.
I have tried the two ways: by the global website tag (gtag.js) and by Google Tag Manager.
On global website tag I am not really sure I could implement it since I tried to modify the source code of the page but it didn´t save.
On GTM y created a tag (GA4 configuration) with "all pages" activators and it shouldn´t be much more trouble.
The thing here is than when I open the Tag Assitant Legacy it just finds one tag GTA tags and it does with a UA identity, even though I always tried to configure the two options above with the new identities G-XXXXXXXXXX.
All in all, I have three questions here:
Is it possible to modify the source code of a webpage? If it is, is it specifically with Medium? If yes, how?
Why does GTA shows just one tag if I tried to configure two?
Why the configured task shows a legacy identity (UA-xxxxxx) if I always used the new one (G-xxxxx).
Just to finish and give the complete picture here, when I try the Tag Assistant, this is what appears. Here I can only recognize the first code (which is the same than the GTA one). Moreover, it sometimes sends the "can´t connect to the website message" once in a while.
So much problems, so many questions; if anyone can help I would really appreciate that.
Thanks so much!

Google Analytics, iframes & cross-domain

I have GA on every page on one domain (actually not me, but my company, whose programmer needs auditing). Just the default code (Classic version, ga.js), no special accommodations whatsoever that I've seen or know of. Bare minimal if any configuration past registering the service with the main site...
All the pages are either aspx or static HTML. It's common practice for this guy to embed pages on the site within other pages on the site in iframes, where both the parent (top-level) & child (embedded) pages contain the GA script.
I don't really know much at all about GA, have never worked with it, but I do suspect that might result in extra hits being counted by GA or something, that that may be messing with the metrics. But then I've read stuff about GA using first-party cookies so by default pages loaded in iframes won't be tracked/counted... I could really use some clarification on this, please.
Then our programmer frames pages from the main site in pages on other sites that we own, that are on different domains. So then there's this cross-domain business, with no segregation of sources, because they really don't care much. So what should be the outcome of that? The external sites' pages don't have the GA code.
However, we're rebuilding one of those other sites - actually I am, for the most part - and the programmer told me to just copy and paste the same exact GA script used on the main site into that one. So, it's a different domain. That wouldn't work as-is, would it? Wouldn't there have to be some sort of special configuration, setting of the domain, something?
I'd really appreciate if someone could tell me more about the scenarios described above. Thanks in advance.
In the Google Analytics developer menu, you can create a new 'profile' for this new site. The analytics will then be tracked for just that one site, not for all. In theory, it is possible to use one GA.js for all your sites, but it kind of kills the whole concept of Google Analytics, so it's not recommended.
Your really shouldn't be using iframes anymore IMO. There are reasons to use them like embedding code for tracking etc, I think, even GA uses iframes. But, generally Google doesn't like them because a lot of spammers use them to try and fool the Google Crawler.
Also, it get's very complicated to understand what is going on within GA.
To answer your question: Each iframe is like an independent webpage completely separated from the other webpage (for security reasons). So when Google or a web browser goes to your website it will do this:
Load your main html document.
Render that page.
See that you have an iframe.
Load that page in the iframe.
Render the iframe.
Now, if you don't have GA installed on the iframe page it will not track the page being loaded.
But if you do put GA in the iframe it will record when the iframe is loaded or the webpage is loaded.
But, remember that one of the main reasons of having GA is to see where your customers are coming from and why. If you have an iframe of another webpage, you really don't know if that is because a customer is:
A) visiting your website from the page directly.
OR
B) the customer is visiting that page through an iframe on another page.
It can get very complicated
You must generate a new tracker for each domain you are using. Otherwise what is to stop someone from just copying your GA code, and putting it on their webpage.

Cross Domain iFrame auto height resizing

I've been googling and looking at various options but could not seem to be able to find a perfect solution that works in what I'm attempting...so needing some help here.
The situation/environment that I have is the following:
Parent page (which has the iframe) - is on a different domain, and the only control I have is a portion of the body tag, where it is updated via an admin console using html/WYSIWG editor. No access to head tag or even hosting jscript in their domain.
Child page (iframe) - is hosted in our domain, and we have full control.
The parent site is actually 3rd party online stores where we have products there, and we want to put in common information that we can control on our end without having to edit each individual product listing one by one.
I've tried alot of options found but it does not seem to work as either they need to include in js file or access to the head tag in the parent page.
So wondering if there are any other options that can help us on this?
I'm afraid you need access to JavaScript on both domains to do this.
Could you get the 3rd online store to host a small JS library that all their clients could then use to solve this problem? I work on a project that allows third parties to add in iFrames and produced this little project for just this reason. When any one say they want to be able have their iFrame resize to content, we point to the iFrame js file and say include this on your page.
https://github.com/davidjbradshaw/iframe-resizer
Sorry, that's not quite the answer your after, but trying asking the store to support this and they might be open to the idea, as I expect others have the same issue with their site.

Web crawlers and IFrames

Hypothetical Situation: I have a small obscure website called "miniatureBoltsInCarburetors.com" which provides content about the miniature bolts which hold a carburetor together as well as some general related automotive information. My site also has a single page which allows someone to find the missing bolt in their carburetor, and while no one will access this page directly from my website, one billion other popular automotive sites have embedded this single page in their website using an iframe, yet not included a link back to my site.
I recognize that this question is related to SEO which is considered off topic, however, all of the many SEO related forums discuss the marketing steps one could take, and not the programming steps or strategies, and hope others will allow this question to be answered here.
I wish my site "miniatureBoltsInCarburetors.com" to be ranked high for general automotive searches. What could I do to allow the 3rd party sites which include an iframe back to my site to improve my ranking? Could using JavaScript in the iframe to create a link on the parent page provide any value? What about when my server renders the page, use PHP to get the referring URL from $_SERVER, and include it in the content?
I am providing a solution here. Not sure if this is what you want though.
In your page which is used by other websites in iframe you can put below Javascript. This javascript checks if the webpage is opened inside an iframe or directly in browser.
So using this check when you see it is opened in an iframe. On click on something navigate to your website.
// This works in all browsers
function inIframe () {
try {
return window.self !== window.top;
} catch () {
return true;
}
}
Also for your reference you can check the below URL.
How to prevent my site page to be loaded via 3rd party site frame of iFrame
Hope it helps.
Iframes are seen seperate pages by Google. Your approach may end up being penalized due to being sourced from untrusted site. According to Google Webmaster Support
Frames can cause problems for search engines because they don't
correspond to the conceptual model of the web. Google tries to
associate framed content with the page containing the frames, but we
don't guarantee that we will.
One of the best approaches to rank higher for a specific keyword is, make multiple related sites. In your case a 3-4 paged site about carburetors, bolts, other things your primary site contain would do it. These mini sites will be more intense about the subject due to less page count. Of course they should contain unique articles on each page. Then link from mini websites to primary websites and you can see the dramatic change.
In fact, the thing you are trying to do was a tactic to rank competitors down worked occasionally a few years ago. Now, it is still a risk.
I see. You don't want to mess up the page for your own site, but you want to do something with all the uncredited embeddings.
The solution is fairly simple:
Create a copy of the page.
Switch your site to use the copy.
Amend the version that countless other sites are embedding, so that there is a small link back to you. Or, add an iframe blocker script that will load your site.
If the page is active (ie user interacts with it to find the missing bolt) you could include a sales message with the response encouraging the user to visit your site.
I think that your goal is getting your link onto these other sites long enough to get indexed by Google before it is noticed by the people doing the embedding, so it's a bit of a balancing act.
I see conflicting advice about how Google indexes iframes. You should use a PageRank checker to see if the existing iframe page url has PageRank, and compare it to the page that you embed it on.
I dont Think you need to worry ,.
Google bot does seem to crawl through Iframes ,but the Web-Page Containing that Iframe is not Credited for that Content .. In other Words,, Page-Ranking of that particular Web-Page do not Change due to Contents from Iframe .
is IFrame crawled by Google?
Do robots crawl iframes?

Resources