Track number of impressions of a widget running on a remote website - iframe

I have created a widget that is being hosted on a number of websites. I originally implemented the code using only jquery and JSONP to buid the widget. Upon implementing the widget on live webiste though we had the unfortunate experience of that other widgets which were on the site already had really poor javascript in them which killed our widget, so to cut a long story short I have created a second version which works using an IFrame. I have read up on the google analytics site that you can track usage in an IFrame fairly easily, but is there any way that I could track the usage of the original, iframeless version using Google Analytics. I could of course simply have an app on my side which counts the number of time the webservice I'm using to render the widget is called, and count the number of referrals on my site, but this seams like re-inventing the wheel when we already have Google Ananlytics to do this.

I don't think it's reinventing the wheel since Google Analytics is not designed to do this.
The advantage of having an iframe is that the content of the iframe is on your site, and thus under your control. With your plugin on the wild everything you do is shared with the global page namespace and in the same manner the other extension killed yours, your extension could have killed others.
If you implement analytics on your extension you could be impacting the site very heavily if it also uses Google Analytics.
Multiple trackers on a single page is tricky in Analytics. It's possible but not very well supported and not recommended by Google.
The problem happens when you have conflicting Google Analytics settings with the other trackers on the page. Since you're sharing the same cookies both tracker configurations must be compatible.
eg:
If one uses _setAllowHash and the other does not the cookies will be reset for each time a pageview is fired, possibly breaking both implementations pretty badly.
So if you have other means to track your extension go for it. Try to use Google Analytics only on your domain, so you're free to go if you're doing it inside your iframe, otherwise try to avoid it.
If you can update the other extensions that are out there, why not just replace it with the iframe versions of it?

Related

Wix template sending tracking via fileusr to my site - causing Google Analytics to view traffic as referral

My website is hosted on wix.com . Wix does not allow you to insert HTML code directly in the page of your web site. When I input HTML code, Wix inserts an iframe that is hosted from a different domain (filesusr.com). This iframe does not use Google Analytics tracking, so when the browser loads this iframe GA believes my customer has "left" my web site and gone somewhere else. When the iframe loads, the original source of the traffic is lost.
From the research I've done, it seems this Wix feature does not work with GA traffic tracking, and so there is no solution other than using a different hosting platform.
However, I'm sure you clever folk know otherwise!...
Right, Wix is notorious for being a "widget" based platform that does not play nice with custom code. However, the whole GA different-origin thing is such a common request that they implement the tracker directly themselves if you plug your GA ID into your site settings. Any reason you are not using this? - https://support.wix.com/en/article/adding-your-google-analytics-tracking-id-to-your-wix-site. They also claim to support other custom tracking snippets - make sure you are pasting it into the "Tracking & Analytics" section and not as a custom HTML widget.
If for some reason you can't or don't want to use the above methods, it used to be that you were just out of luck. There is a reason why Wix is not as favored as other platforms by digital marketers that need to implement tracking code. However, if you were really determined, you could probably implement a very custom GA tracker or any custom code through their new feature called Corvid, which exposes internal APIs and extra coding features. How to do so is beyond the scope of this question, but the postMessage() method is the normal way to pass messages from a parent to a child (iframe) container. Or you could use wix-fetch, which is an internal version of the web API fetch(), to manually send a hit request to GA.

Is it OK (in google analytics) o have some pages with the GTM and others with analytics.js?

Per my answer here I have some pages using Google Tag Manager to report Google Analytics and some that report them directly using Analytics.js.
It seems to be working OK but I wanted to see if there were any issues I should be aware of.
You would need to make sure that whatever you are tracking with on-page code on those pages that don't have GTM are not already being tracked through GTM.
Generally speaking, it's not advisable to mix both GA and GTM on the same site (unless you are in the middle of migrating one to the other). So either go all GA, or all GTM (I usually always recommend going GTM). Otherwise there could be conflicts. It goes without saying that you should always test everything, too.

Can I use ga.js in one page and analytics.js in others and consolidate the results?

I have a website that has a landing page built and hosted on a website development platform (Wix). I have no control over the code, and to use Google Analytics I can only input the Property code and it's automatically implemented. The thing is that they still use ga.js, and the rest of my website, hosted in my own server, uses analytics.js.
I thought about using different properties, but then I wouldn't have the data all in one place.
Is it possible to consolidate the data? If not, what is the best way to deal with it?
Thanks.
==== [EDIT] New info.
Thanks MarkeD and Marcel Dumont. Using ga.js with another property seems to be the way to go, but there's another issue. The landing page in Wix is the www subdomain, and when the user goes to my server it goes to another subdomain, so I'd have to add "pageTracker._setDomainName('mydomain.com');" to the Wix page tracking code, which can't be done.
Any new ideas?
Thanks again.
Afraid that out-of-the-box there is no satisfiable solution for your issue.
You cannot use the old and new method within one profile, and there is no method to consolidate data across two profiles.
Even if you would put in a lot of efforts use the APIs to manually query and consolidate both profile data into your own Database/Dataware house you would still face problems with the inability to add visitor/visit data together.
As workaround, why not run old-style GA next to your Universal Analytics on the rest of the website? not ideal to use old-style, but at least that will give you overall data.
The old ga.js will still send data to a Universal Analytics property, so you could run both into the same account, once it is upgraded to Universal Analytics.
Google reference on upgrading from ga.js and analytics.js
Note that the reference states if you have ga.js and analytics.js on the page, it will double count. (i.e. data is sent with both)
So I would put the same UA code on your Wix as your ga.js main website, and use as normal. The data will be a bit more flaky as the sessions are calculated slightly differently under the two scripts, but when Wix finally upgrades to ga.js that should sort itself out.

Google analytics and slow load

I'm a bit new to this and a total non-techy. Basically the site I work on doesn't currently have much in the way of analytics other than the standard GA reporting and some events as and when reporting has been required by marketing. I come from a background where the site I worked on had a different analytics tool and pretty much every click event or interaction on the site could be reported on. This made it really easy to pull off analytics on any area of the site as and when required in a more proactive way without the need for dev work.
The developers I am working with now are telling me that if we were to put events on the core areas of the site I have asked for (ie core user journeys and key features), it will affect the load times of the pages too much. Could someone advise, 1- is this the case with GA? 2- is there any way around it? 3- is this an issue unique to GA or any analytics tool
This is not an issue with Google Analytics or any web analytics tool. Google code is loaded asynchronously (so it can't block page load) and by the time the events are attached the page is already loaded (else attaching events would hardly be possible).
It might be that your developers are concerned that page performance (not load time, though) suffers when they add a script that has to modify every single DOM element. That argument might have merits (hard to say without knowing your site) but has nothing to do with the analytics tool.

Google Tag Manager vs. Google Analytics

I'm attempting to learn how to incorporate Google Analytics and custom event tracking on a new website. After researching into it, I can't seem to understand the difference and relationship between Google Tag Manager and just writing custom event tracking code.
Is Google Tag Manager just an easier way to track information without having to write JS?
Yes - Google Tag Manager is a "Tag Management System" wherein you can implement a lot of tags external of a typical development release cycle.
Adding tags without efficient management prompts big problems. All that code bogs down your site. Redundant or incorrectly applied tags can distort your measurement and result in duplicate costs or missing data. And it can be time-consuming for the IT department or webmaster team to add new tags, which means important marketing and measurement programs can be delayed. With Google Tag Manager, you eliminate these problems—and run your campaigns when you need them. -- source
Marketing and tracking services provide “tags” — snippets of code you’re often asked to embed right before the end of your tag — and they’re relatively easy to use, but when more than a few tags are involved, managing them can be a tedious task. This is where Google’s new Tag Manager comes in, which consolidates all of your site’s tags into a single admin panel. Now, you only have to include one automatically-updated snippet on your site. -- source
A Tag Management System (TMS) is solution that controls the deployment of externally hosted Javascript "page tags", very similar to what a Content Management System does for content. Probably the most known tag-based application known is Google Analytics, but other apps include simple social media interactions such as the Facebook Like or Tweet This buttons to more complex systems such as the Intense Debate or Disqus comments systems. -- source
So in your question, you can implement google analytics via custom event tracking code or you can install google tag manager and then code all your custom google analytics event hooks in it.
The google analytics is for user tracking and website traffic analysis and statistics.
The Tag manager is to manage plugin to website like google analytics basically they are different.
You could add google analytics to your tag manager account and the only plugin you will add to your website it the tag manager
i have tried this already.
hoping this was helpful.
thanks (=
Let me share my experience of implementing custom event tracking with Google Tag Manager.
Goggles Tag Manager (GTM) is a layer between your website and Google Analytics (GA).
We can use GA code for event tracking but in this case we have to write JavaScript in the website code. We have to look for event and need to add GA code inside that event handler. Since we have updated code, now we have to wait for the code release cycle to make it available to live site.
Using GTM it is possible to handle custom event tracking without adding code to the website and we can test our implementation with GTM inbuilt debugger before deploying to production website, at anytime.
And there is one more design pattern where we can implement generic custom event tracking for the whole website without adding JavaScript, but adding data-attributes to links, buttons or div- what ever event we want to track just add your data-attributes to the link and those attributes will go to GTM trigger and if it matches the rule, that event will be tracked. This design pattern is good for any kind of generic custom event tracking. I have implemented custom click tracking number of times using this pattern, and I am happy with it.
Google Tag Manager makes tagging easy as it has quite a few builtin dom variables and event handlers for Click, Pageview, Custom Events etc.
It also allows you to manage various external vendors and sends them the data they need. (I.e., Facebook pixel)
It really is a great eco-system for non-developers to get involved in tagging and event tracking.

Resources