How to use Google Analytics to track cross-domain image loads? - google-analytics

I have a simple-cheezy web site set up on Neocities for the single and sole purpose of hosting a single image. There is no other content, and this free web-hosting service exists only to host the single image. The reason why I am hosting the image here, is that I have another web hosting service provider where I wish to display the image, but the second provider does not support Google Analytics; Neocities does.
I'd like to embed the image (which is my organization's logo, so it's use is legal and users aren't getting stuffed with the typical, rogue blank gif). Sounds like Google Analytics could simply track image loads, where the image is hosted on Neocities and loaded via page views to the other web page.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>The web site of abcdz</title>
<!-- The style.css file allows you to change the look of your web pages.
If you include the next line in all your web pages, they will all share the same look.
This makes it easier to make new pages for your site. -->
<link href="/style.css" rel="stylesheet" type="text/css" media="all">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-xxxxxxxxx-2', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<a target="_blank" href="http://www.abz.com/abcd/index.htm" id="anch_90" style="display: block; width: 80px; margin: auto"><img class=""
src=" http://abcdz.neocities.org/logo.png" width="200" height="260"
alt="Organization Name."
title="Organization Name."></a>
</body>
</html>
So back to my second web site, I embed the following, so users see my organization logo, and when they click on it, a new page opens to my organization home page. Just to reiterate, the second web host does not support Google Analytics, only simple HTML customization (I can't access head content), it is something like a CMS-style application.
<a target="_blank" href="http://www.abz.com/abcd/index.htm" id="anch_90" style="display: block; width: 80px; margin: auto"><img class=""
src=" http://abcdz.neocities.org/logo.png" width="200" height="260"
alt="organization Name."
title="Organization Name."></a>
Set up GA, seems to be working, when I visit http://abcdz.neocities.org/, GA statistics register the hit.
When I visit the other web page, which is loading only http://abcdz.neocities.org/logo.png, no GA "hits". Obviously, GA is tracking page views, but no tracking access to the logo.png that is embedded in the page but accessed cross-domain.
Certainly other people are doing this successfully, but how?

You can use Google URL builder to be able to track the image itself. Here is the directions for that: https://support.google.com/analytics/answer/1033867?hl=en
I am referencing this answer post on the Google Product Forum.

Google Analytics does not track images since images do not contain tracking code, so this is not caused by cross domain issue (it is in fact expected behavior, unless I really misunderstand your post).
GA tracks pages which are composed of multiple assets like HTML, images, scripts etc. Most people would not event want their assets tracked individually and are quite happy with page tracking, so there has been no need ever for Google to invent a workaround.
You can track when the image is successfully loaded into your html page (by using the onLoad-event of the image) but that does not seem to be what you are after.
You cannot track images that are called directly (unless they are really scripts that output an image after sending a server-side request to Analytics which does not seem feasible in your case).

Related

Will Google Tag Manager work without <body> part of code?

When installing Google Tag Manager I have to add 2 code snippets into my website: one into the <head> section and the other in the <body> section. The website CMS I'm using (Teachable) doesn't give me access to the <body> section, only the <header>.
Is there a way to install Google Tag Manager properly without access to the <body>?
I tried putting both code snippets in the <head> section.
The <body> part is not needed.
The <body> part is just a <noscript> part of GTM. GTM is a js framework. The only thing <noscript> helps with is loading only pixel type tags when client has js disabled.
But people don't have js disabled. Also, it's likely that your site doesn't work when JS is disabled. Also, at the point when JS is indeed disabled, firing pixels is very likely the least of your concerns. Noscript is the remnant from the past, effectively.
I normally never install the noscript part of GTM.

Modify Css of Microsoft Qna Maker

So I have QnA maker set up and connected to our Azure (I am totally new to Azure). I need to change the CSS of the Iframe from QNA maker, it is currently blue (as the default). I am following this guide to make it our company's colors:
https://blog.botframework.com/2017/10/11/customize-web-chat-websites/
I need to be able to clone this: https://github.com/Microsoft/BotFramework-WebChat/tree/master/src (which I already forked) into the current Azure build, which I am ultimately having a problem with.
I am sure I am overlooking something simple in Azure, but I just need to clone the source code to properly add the .css files I need to be able to edit the bot.
Currently, I have tried to grab the Iframe and change the CSS that way, but no dice (of course). All I need to do is change blue, to red, any way to do that will be helpful, whether that is changing the Iframe after it loads or by getting this guide to work for us. Thank you!
Refer to the github readme for more detail: https://github.com/Microsoft/BotFramework-WebChat
There are options:
Easiest: In any website, IFRAME the standard Web Chat channel
Easy: In your non-React website, run Web Chat inline
Easyish: In any website, IFRAME your Web Chat instance
Medium: In your React website, incorporate the Web Chat React
component
According to your requirements; running the bot in an iframe with custom style, you should read the Easyish section:
You can isolate your instance of Web Chat by running it inside an
IFRAME. This involves creating two web pages:
Your Web Chat instance, as shown above. (refer to Easy)
The hosting page, adding <iframe src="/path/to/your/webchat/instance" height="height" width="width" />
Based on the Easyish section (step 1), you need to first complete the Easy section. In your existing web app, add a new page with the following code (enable directline on Azure Bot settings):
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
</head>
<body>
<div id="bot"/>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script>
BotChat.App({
directLine: { secret: direct_line_secret },
user: { id: 'userid' },
bot: { id: 'botid' },
resize: 'detect'
}, document.getElementById("bot"));
</script>
</body>
</html>
CUSTOMIZE your chat box style by editing the botchat.css file. You make a copy from https://cdn.botframework.com/botframework-webchat/latest/botchat.css and edit to your liking and put your own customized botchat.css to somewhere in your web app and change the href in the header instead of using the default one.
Finally for Easyish section step 2, you can create an iframe (content is step 1 web chat page) and embed that in your hosting page.

Why Google Tag Manager is not always implemented as it is in the Google Demo Shop?

got some questions about the Google Tag Manager snippet. If I'm looking at the Google Demo Shop website the GTM implementation is like this :
<head>
<script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-XXXXX"></script>
... some stuff ...
<noscript> <iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-5Q5LZH');
</script>
</head>
So basically everything is in the header. So first question, what is this line for :
<script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-XXXXX"></script>
Second question, I've read that the code below:
<noscript> <iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-5Q5LZH');
</script>
could be implemented just after the opening of the body tag... and I've seen this a lot.
Is there some real differences between these different kind of implementation ? It doesn't seems to make any differences for Google Tag Assistant.
Thanks !
Initially Google Tag Manager recommended that the GTM snippet be located in the <body>, however it has recently updated its recomendation for it to be in the <head>.
This is most likely due to two reasons.
1) Apparently there were concerns about the way that the GTM library made modifications to the document object model which might have lead to conflicts for IE7 or older.
2) The <iframe> within the <noscript> is embedded content, rather then HTML, which is not allowed in the <head> of the document.
Recently Google has updated its guides and documentation to show a split implementation, with the in the <script> in the <head> and the <noscript><iframe> in the <body>.
This makes sense, as there is no reason why an asynchonrous JavaScript library needs to be in the <body>. As with all tracking its ideal to have the dependencies loaded as early as possible to ensure that your tracking is available prior to the user interacting with the website. However due to reason 2, the <noscript><iframe> is still recommended to be placed in the <body>.
So, to answer your questions:
1) the implementation on the Google Demo Store is incorrect, the entire code should not be placed in the <head>.
2) The <script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-XXXXX"></script> in the Tag Assistant is not the actual code, but how the Tag Management extension interprets the code.
3) The <body> implementation was the previously recommended implementation, which is why you have seen it a lot.
4) Going forward, I would recommend the implementation advised by Google when setting up a Google Tag Manager container, spiting the placement between the <head> and the <body>. This means that GTM will load as early as possible, with an iframe backup if required.
5) Tag Assistant merely checks the code against rules manually set within the extension. The obvious caveat of this is that the extension needs to be kept up to date. An example of this is that recently the GTM container id's moved from 6 to 7 characters however the extension was not updated, leading to a lot of people getting errors in the Tag Assistant stating that their container ID was incorrect.

Improve my site performance

I have a static only site which is hosted on Google App Engine. Infront of this sits Cloudflare CDN.
I have ran Googles Page insights to give me an idea how my website is performing, it is not performing well according to Google. I want Google to see it is performing well for SEO purposes.
This is the report I get from Google:
2 types of recommendations come:
1) Eliminate render-blocking JavaScript and CSS in above-the-fold content
Show how to fix
2) Leverage browser caching
For problem 1 I have tried many things I have read on Google. I have tried adding 'aync defer' to the link attribute. I have tried to make the media = print so that the browser would first render the html then apply the css later. I have tried moving the links to the stylesheets into different locations around the html document. Essentially I have tried to follow this: https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery.
As of right now my html page (my website is just on static html page) structure looks like this:
<html>
<head>
<!-- all links/references to css files and javascript files -->
</head>
<body>
</body>
</html>
My second issue is browser caching which I do not understand why I am getting this error. Google App engine caches the files and then on top of that Cloudflare CDN sets the cache headers (and also gzip) on the documents so that the browser caches it (below is the Cloudflare caching components turned on).
I can see the browser is caching the static files and using those cached files in chrome tools when I run the page:
This is really the first time I have created a production static website so I may be misunderstanding many things, but I am looking how eliminate those 2 issues.
Cheers
I don't know if google is measuring this but it is often advised to load Bootstrap and Jquery from the following addresses as they are used by a lot of website and hence are already in browsers caches even if they never visited your website. (The same can certainly be found for font-awesome).
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/YOUR_BOOTSTRAP_VERSION/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/YOUR_BOOTSTRAP_VERSION/js/bootstrap.min.js">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/YOUR_JQUERY_VERSION/jquery.min.js"></script>

Google Plus Share Button not showing description tags... an Unannounced Google Platform change?

OK guys, tell me what I am doing wrong... Is this a new Google Plus issue? Or — to use an old Facebook term I created — an Unannounced Platform Change? (note the date of this question)
Please Note that I'm asking about Google Plus Share Buttons, not the GP+1 like button which is a different beast…
The Description Tag is not passed thru to the share window or to the Google Plus page post. If you inspect the Google window code with Firebug, you will see this:
<div class="Zm"></div>
…which is where the description tag should display.
Demo and source code located here.
Now...
The demo and the more complex script are both HTML5 validated. I have tested this with both schema.org tags and open graph tags:
All Tags work fine in the Google Structured Data Testing Tool here.
Results are the same in both cases: description tag does not display, so that's not the problem.
I have tested this on http:// and https:// with the same results: description tag does not display, so that's not the problem.
I have tested this on FF22.0 with and without AdBlockPlus && Chrome 28.0 and the results are the same: description tag does not display, so that's not the problem.
I have tested different button types with the same results: description does not display, so that's not the problem.
And I have googled for hours… and cannot find any "current links" to this issue that are not simple code errors.
So what part of this am I missing?
Any ideas, comments, suggestions or solutions would be greatly appreciated!
Google+ dropped the shared page's description.
You can find indications of that by looking at the "Basic Page" example at https://developers.google.com/+/web/share/ which used to show a description until several weeks ago. The current status of Google documentation clearly shows that a "description" is not expected or used anymore.
<html>
<head>
<title>Share demo: Basic page</title>
<link rel="canonical" href="http://www.example.com" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
</script>
</head>
<body>
<g:plus action="share"></g:plus>
</body>
</html>
So, the only important tags are:
the "page title",
and — optionally — the "canonical link" (for SEO reasons).
That's it!
Obviously, Google downgraded website descriptions to less relevant in Google+ just like they did in their search engine a long time ago.
Most probably this was done for the same reasons Google once started to put less emphasis on the description of pages in their Search Engine product too: to avoid spam and keyword stuffing from polluting their Google Search and Google+ products.
For additional, "official" reference that Google generally marked descriptions to be "less important" a long time ago, check https://support.google.com/webmasters/answer/35624?rd=1 which states in the section "Create good meta descriptions":
...Google will sometimes use the meta description of a page in search results snippets, if we think it gives users a more accurate description than would be possible purely from the on-page content...
Well, "sometimes" obviously does not include Google+ (anymore) and — to be honest — I see their point. After all, you can (and should) "describe" the link in your Google+ post textarea yourself… which would also be the most logic thing to do: tell your users why the linked website is worth visiting instead of relying on a site's description.
You can use Google Snippet via meta tags to inform google what to display when your link is shared... You can view details # https://developers.google.com/+/web/snippet/ (Customize the snippet people see when your page is shared. Using this tool, you can generate code for your page that indicates the images and text that best represent what's being shared.)
<!-- Update your html tag to include the itemscope and itemtype attributes. -->
<html itemscope itemtype="http://schema.org/Article">
<!-- Add the following three tags inside head. -->
<meta itemprop="name" content="Title For Example.com">
<meta itemprop="description" content="Sample Description For The Article..">
<meta itemprop="image" content="http://www.example.com/1.jpg">
Hope this helps.

Resources