How to add multiple Google Analytics trackers on website? (HTML, JS) - javascript

I'm working on a portfolio, and I had an idea to add a section saying:
"My work has been seen by this __ many people."
In order to do this I have settled on using ShowMyStats, but in order to get that stats, I need to add another Google Analytics tracker to all the websites I manage. Is this possible? I've seen something answering this question here on stackoverflow, but it didn't work. Any ideas? All help appreciated.
Original post

It's best to use GTM to manage your ga trackers/properties. It becomes a trivial task that way. Here is a good article that goes quite deeply into the matter: https://www.simoahava.com/gtm-tips/send-google-analytics-tag-multiple-properties/
Another concern here is that it seems unlikely that an extension like that requires a new property. Why not just feeding it your existing property?
Your older question's accepted answer actually answers the question pretty well. Provide your debugging and fixing efforts for us to be able to move forward.
Finally, Google is deprecating GA UA, so you probably want to stop doing it for UA and start implementing it for GA4, which makes your code snippets obsolete, but also makes a good case for using GTM, since switching from UA to GA4 via GTM is a lot easier than via code. GTM tends to do its best to abstract the code from the users while still allowing liberal code injections.

Related

How to detect ads?

I am trying to write a browser extension that will detect advertisements. I don't want an AdBlock, I just wish to detect how many ads are encountered. I don't know where to begin searching for ads in the HTML, though. Any help for a good first start?
Most adblockers catch the ads via some form of a regex match.
I would recommend you to start with the adblockpluscore repository, since it's open source and you can quickly run through the source code.
Start with the test directory, particularly peeking into the patterns.ini file and see the common patterns, when determining different sources of ads.
Search for these sections in patterns.ini:
General tracking systems
Third-party tracking domain
You can expect, that your initial solutions won't be too effective, since ads come in different forms of data, but you'll find common patterns between many of them.
Ads vary, but I think that Google Ads uses an ins element. I can't seem to put the tag into the post, it comes out as nothing: , but you can see the code on google's page: here.
So you can search the page for an ins element and add it to a counter, sort of like the following extremely simple/barebones code:
$.fn.count = function(selector) {
return this.filter(selector).length;
};
If this doesn't work, look at this SO question.
Remember that this is just to get started and will not work 100% of the time. AS wOxxOm pointed out, ads are complicated.

JavaScript Best Practices: How to implement long-lived apps (one-page web apps)?

Are there any best practices for implementing a long-lived JavaScript app, i.e. a web app that consists of a single page and loads other pages into the content area via AJAX? (Gmail is a good example of this.)
I already read about pro and cons, SEO, performance, etc. (http://stackoverflow.com/questions/1499129/one-page-only-javascript-applications), I'm interested in patterns how to implement this.
I'd like to avoid large frameworks (e.g. Cappuccino, Echo2, SproutCore, Claypool).
How would I manage dynamically loading content while maintaining the #link portion of the URL (for bookmarking)?
Don't get me wrong, I have an idea how to implement this myself, but this problem must have been solved before.
Are there articles on this? Maybe a tiny JavaScript library?
Thanks!
Mark
I found JQuery Address http://www.asual.com/jquery/address/ extremely easy to set up. $.address.change() let's you know whenever something was clicked (works with back and forth as well) and you just parse self.location.hash and build your app from there. It seems lighweight enough as well, if you can handle using JQuery.
Here is an article to help you with the History bookmarks problem: http://codinginparadise.org/weblog/2005/09/ajax-dhtmlhistory-and-historystorage.html. It's quite old, but the solution still works.
I made several apps using this "long lived" apps, and one thing you should take into account is IE's tendency to leak memory.
I would also recommend you to use a JS library, like JQuery to help you with the AJAX and DHTML.
Heard about javascript pushstate?
http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate
It's meant to replace location.hash

Alternatives to GWO (Google Website Optimizer)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
We're using GWO (Google Website Optimizer) now. The multivariate and A/B testing is exactly what we need and works great from the perspective of showing the variations to the users. However, we have several issues that make me want to use a different tool:
Statistics are inaccurate compared to Google Analytics, so we now disregard them and have to manually check
Previews typically don't work
Cannot have dynamic content in variations (I know about variation_content, but I cannot get it to work and nobody in google's forums has been able to help.. I suspect google may have stopped supporting this)
Documentation is poor, there's a techie guide with well-known inaccuracies which haven't been fixed in well over a year.
The html/javascript code we modify our multivariate test sections with is ugly and makes our pages fail standards validation
Only 8 test sections per page, problem there is we want to allow our marketeers the ability to do everything they need from within GWO, but now they need to mark off which test sections they want/don't want in our custom tool
Different experiment key for every test, again it makes marketeers need to work with our code sometimes
Is there a good tool like GWO that works with Google Analytics (which I love)?
UPDATE: We went with Optimizely and have generally been happy. However, it can be difficult to work with because it does a little too much for you. You edit your webpage directly from their UI, but of course that isn't always easy or even possible. Particularly when Javascript is involved. Our UI often gets screwed up in the process. I liked GWO's approach to this in that the developer sections off the code and the marketer can then fill in those sections with variables the developer allows for. To me that's ideal, except that GWO, of course, doesn't actually work.
There's a very similar competitor to Optimizely called Visual Website Optimizer. Also looks very nice, but has the same issue I describe above.
Is there a GWO that works?
You should take a look at Optimizely.
Doesn't require creating invalid code.
Easy to create variations on the fly, though only A/B, not MVT.
Simple WYSIWYG test design, on the fly.
Real time data.
Retroactive goals
With regex/head matching for experiments, you can set the experiment to work on dynamic pages.
You can set a Google Analytics custom variable for the experiment that will pass the variation the end user sees as a custom variable. (It even allows you to set what slot you want it to use.)
The test variations are basically just jQuery manipulations of the DOM, so if you know a little jQuery, it's very easy to extend its capabilties even further than the very generous WYSIWYG GUI.
Installation is easy: You only need to include a single script tag, one time, on any experiment or goal page.
I have found Adobe Test&Target to have all the features you need. It is very easy to create experiments, add variations, and conversion goals. You can easily inject JQuery snippets to create new variations, click Save, and the test is running in production.
I have no idea how much it costs, but I'm guessing it is not cheap.
Now Google Website Optimizer killed multivariate testing in new version (Google Analytics Content Experiments) we launched Convert Experiments on Convert.com for people that look for a GWO alternative with MVT
Yes I am Founder of Convert Insights, the company behind this tool...
Dennis
Re your update: I have tried both GWO and Optimizely, and I'd go with Optimizely every time.
You say you wish it worked a little more like GWO - if you want, instead of manipulating the elements of the design using their GUI, you can just redirect each variant to a different URL:
https://help.optimizely.com/hc/en-us/articles/200040675
There are a few other tools which do A/B and MVT. Aren't free, but check them out for yourself: Omniture, Webtrends Optimize, SiteSpect.
Hope this helps!
You can also try VWO. It does MVT as well as A/B testing and is also a good tool. Optimizely is easier to use though so you might want to evaluate both for your scenario.

Does google analytics slow down my website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am at the final stages of my website, and currently I need to find a suitable statistics application/tool.
I have looked into webalizer, but it seems outdated.
Also, I have looked into Google analytics, but I am afraid that if I implement it, my website will go slow. It is already pretty heavy with database material being displayed which is dynamic btw.
I have read I can put the GA js code at the bottom of the page and thus the page will load first, but I still don't want a slow down.
You are all much more experienced in statistics than I am, so I believe you can give me some good advice.
I have my own private server (Linux) and I have root access as well (offcourse).
Do you think I should have a statistics app on the server, without interferring with my website, or should I go the Google way and use analytics?
Please give me good application names which you have tested etc...
Thanks
Any additional calls to scripts will slow down your site. However, Google Analytics instructs you to place it in a specific place so that it isn't loaded until the page has loaded. (It used to be before the </body> tag but I believe it's now supposed to be the last <script> in the <head> tag.) Don't worry about it too much; the benefits of analytics will far outweigh the extra call to a remote file.
Focus on other optimizations (database queries, CSS sprites, fewer HTTP requests). Analytics is necessary in today's site market and is indispensable; IMO it is not an option to forgo it.
As far as having your own "statistics app," I assume you're talking about building your own proprietary statistics codebase? I would discourage that, because it takes a lot of time and effort and in the end you will not have the same optimizations that Google has employed an entire project's worth of software engineers to make. Remember that while it's always great to create your own product, you don't have to reinvent the wheel, especially when it comes to things like this that have many sensible drop-in solutions that are widely available for free.
With respect to non-Google analytics solutions, one other of note is Clicky. I'm not as experienced with it as I am with GA, but I've heard many reviews that it is more precise and more informative than GA. However, just as an end-user browsing the web I've noticed a lot of times that its calls to Clicky's website do tend to slow down pages, and noticeably so; I cannot really say that I have seen the same effect with GA.
One last thing I would caution against is this: Do not employ more than one analytics solution unless you are trying to find the best one to suit your needs. It's just overkill to run two remotely-hosted analytics solutions on every single one of your pages, so what I would encourage you to do is try out a few for the first few weeks or so of your site (yes, pages will slow down during this trial phase) and then simply stick with the one that you like best. That will also give you the added benefit of being able to see first-hand what the speed implications are on your unique hosting environment for each script.
Here's some other analytics solutions that you might check out:
Piwik
Webtrends
GoingUp!
Yahoo! Web Analytics
Straight from Google's analytic sign up page (https://www.google.com/analytics/provision/)
"The appearance of your website will never be affected by your use of Google Analytics - we don't place any images or text on your pages. Likewise, the performance of your pages won't be impacted, with the possible exception of the very first page-load after you have added the tracking code. This first pageview calls the JavaScript on Google's servers, which may take slightly longer than a regular page load. Subsequent pageviews will use cached data and will not be affected."
Use the Asynchronous Snippet of Analytics:
http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html
People focus to much on total load times when what is important is render times and in particular progressive rendering. If you use Google Analytics properly, it will load after the page has shown to the user. So yes, it will add a small overhead to every request but because the user can see the page already they probably won't even notice. Just go for it.
Webalizer runs on server side after apache logs doesn't it? That's why it appears outdated, it can't collect as much info as JS can. But it doesn't slow the user down any. You could run Webalizer and Google together for a bit and see what serves your needs best.
We decided to work around the possibility of google's servers appearing to slow our site down. Instead of our users downloading the ga.js file from google's servers we store it locally. The only problem with that approach is that our local copy becomes outdated. So we wrote an application that periodically compares our local file to google's and updates our file accordingly.
Andrew
Google Analytics is javascript based and does not tun on your server. All processing and storage is done on Google servers, so it's ideal if you are worrying about local resources.

SharePoint Client JavaScript Documentation

I'm attempting to improve the usability of a client's SharePoint deployment via JQuery; and am hitting a brick wall when trying to find any sort of documentation of what's happening in core.js (aside from painfully digging through and trying to parse any sort of meaning out of it --all 250kb of it!!!!--) Anyone have any pointers, or documentation?
EDIT:
Sorry, to clarify my question, i'm familiar with using JQuery with SharePoint. My question involves hooking JQuery into SharePoint's own client API. My question is inspired by this post http://www.codefornuts.com/2009/09/forcing-sharepoint-into-asynchronous.html# ; where the author is overriding methods such as "SubmitFormPost" and "STSNavigate" in order to make the UI interaction more "AJAXy".
There's no documentation for core.js and it's really a black box. Any "messing" with it would make your installation unsupported. Because of its complexity and how important it is to SharePoint working correctly, I would be very careful before adding this sort of functionality. This is not a comment on your development ability, but IMHO there would need to be a serious business case along the lines of "we don't care if things break occasionally so things look cooler".
If you really want to continue this I think your best bet is to contact Einar! His is the only post I've ever seen that describes how to do AJAXify core.js.
I'm not entirely sure what you are trying to do, but you may want to take a look at Jan Tielen's work with jQuery and SharePoint. He has some interesting posts about calling the SharePoint web services with jQuery/Ajax to build much richer UIs. These are hosted within a SharePoint web part page using a Content Editor Web Part. I've used these techniques in a couple of applications with great results.
Check out this post for an example.

Categories