i'm have a simple page http://mellowkids.ru/serv-ga/test.php with only a Google Analytics Universe code:
<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-44059933-1', 'mellowkids.ru');
ga('send', 'pageview');
</script>
In Chrome Developer Tools i can see what analytics.js generate a js query to http://www.google-analytics.com/collect (gif pixel) with some parameters.
Something like this:
curl 'http://www.google-analytics.com/collect?v=1&_v=j16&a=1674396045&t=pageview
&_s=1&dl=http%3A%2F%2Fmellowkids.ru%2Fserv-ga%2Ftest.php&ul=ru&de=UTF-8...
How i can grab this link (curl) and print it in page by echo or something else?
I believe you're going to need a browser (it can be headless one like PhantomJS).
In the case of PhantomJS, through netlog, netsniff or something similar you will be able to capture the GET request you need (i.e. http://www.google-analytics.com/collect?v=1&_v=j16&a=...) and print it wherever you need.
Related
Trying to use the latest google analytics tracking code in a site that uses Barba JS but it will not track past the first page, ie the path of the user, any ideas anybody?
The reason it is only working on the initial page is that the default GA snippet implemented using gtag.js only runs once after load. Since you're using it in a SPA setting, you need to manually re-send the page data when you route. Looking at the barbajs documentation, I think it'll be something like this:
// define a global hook, using afterEnter, but you can adjust to enter, beforeEnter, etc as you see fit.
barba.hooks.afterEnter((data) => {
// this hook will be called for each transitions
//data.current.url is the page path.
gtag('config', 'UA-#######-1', {'page_path': data.current.url});
});
use full code provide with google annalitics
https://developers.google.com/analytics/devguides/collection/analyticsjs/?hl=en
in you JS add
(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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
I use analytics.js on a html page behind a hotspot. So the internet connection is limited to certain URLS.
I need to open on walled garden all the URLS used by analytics.js to make work correctly google analytics.
I did add:
ssl.google-analytics.com
*google-analytics*
*doubleclick*
But still need more URLs.
I've tested that adding
www.google.es and www.google.com analytics works ok and no errors appears on the urls called by analytics.js but I can NOT open www.google.es and www.google.com for other devices uncompatibility so I need to know the URLs need to be opened to have analytics working ok.
I found reading analytics.js that there is:
https://ampcid.google.com
https://www.google.%/ads/ga-audiences
google.com(:\d+)?\/optimize\/opt-launch\
I did add this URLs + Folders on walled garden but still not enought.
Can anyone help me on build all the URLS+Folder list used by analytics ?
Thanks a lot.
Added Image I can see on Network from a browser:
Added 2:
I have this script:
<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','https://www.google-
analytics.com/analytics.js','ga');
ga('create', 'UA-48205710-1', 'socialwibox.com');
//ga('send', 'pageview');
</script>
And have problems just when calling ga('send', 'pageview');
without ga('send', 'pageview'); i don't have problems.
Oscar.
The basic endpoint for Google Analytics collecting data is
POST/GET /collect HTTP/1.1
Host: www.google-analytics.com
Additionally, demographics data may go to
http[s]://stats.g.doubleclick.net/r/collect
analytics.js script is loaded from
http[s]://www.google-analytics.com/analytics.js
if gtag.js or google tag manager is used they are loaded from
http[s]://www.googletagmanager.com/gtag/js?id=XXXX
I am new to web development and I would like to verify site ownership using javascript, similar to what Google does with their analytics code. I have a django app that lets users sign up for a service, but I need to validate that they own the site. Here's a very high level description of what needs to happen:
The user signs up and is given a verification code
I generate a snippet of code to put on their site
They return to my site and click 'Verify'
Here's googles code. Can someone break down for me what this is doing and how it's used to verify site ownership?
<script type='text/javascript' id="verification code">
(function(){
// create a new script element
var script = document.createElement('script'),
script.src = '//www.google-analytics.com/analytics.js';
script.async = true;
// insert the script element into the document
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(script, firstScript)
})();
</script>
Let's ignore the js for the moment. Your core question is how to verify site ownership. So I'm going to tackle that first.
What Google is doing is having you insert some code into a webpage that you have control of. The assumption is that if you have control of www.example.com, you can get that bit of code served at www.example.com to someone. And that's a pretty safe bet.
Now back to that code snippet you gave. For one thing, it didn't look familiar to me whatsoever. It must be an older format, because what's current is below:
<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-123456-7', 'auto');
ga('send', 'pageview');
</script>
In any any case, there's a great read here on why Google has changed their approach over time for how it loads this script: http://www.stevesouders.com/blog/2010/05/11/appendchild-vs-insertbefore/
So I have a scenario where I am constantly getting a good number of self-referral traffic to my website. I investigated it further and believe it to be a case of an issue with my cross domain tracking (as I use a 3rd party shopping cart).
What I can't seem to figure out is what I have wrong and why it isn't working. My specific scenario looks like the following
MainSite.com Analytics Code
<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-XXXXX210-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['mainsite.com','checkoutsite.com'], true, true);
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
CheckoutSite.com Analytics Code
<script type="text/javascript">
(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-XXXXX210-1', 'auto', {
'allowLinker': true
});
ga('require', 'ec');
</script>
As for the setup options:
The following domains are added to the exclusion referral list in GA
mainsite.com
checkoutsite.com (the actual checkout is on a subdomain of kiosk.checkoutsite.com but this shouldn't make a difference AFAIK)
mainsite.com 301 redirects to www.mainsite.com
As far as I can tell the 3rd party checkout JS script is adding link decorators as seems to be required Edit: Have confirmed as per the comments below
The links to the checkout cart are Javascript based which result in a iframe popover. They look like the follwing:
<a class="eztixKioskLink tourTemplateId_XXXX" href="javascript:void(0);">
<img alt="" src="http://www.mainsite.com/buy.png" />
</a>
However, I still appear to be getting self-referrals and am completely unable to figure out why. Is there something wrong with my code or my setup? Is there something else I should be looking for?
Any help would be hugely appreciated!
You should be good code wise. You can also exclude those domains as referrers:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#selfreferrals
As you go through the flow yourself do you see #_ga hash's being appended? If not you'll need to reverse engineer the javascript link clicks as the outgoing clicks aren't getting decorated:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#linkerparam
I am Trying to set up Google Analytics with Meteor and always get a Tracking not installed Error.
I have already tried to use the meteor Packets, I have tried to include the tracking code in the Head Section, in the Body section and as a rendered Callback on a template.
I always get the error from the Google Analytics Site "Tracking not Installed"
What is the best practice of GA tracking in Meteor Apps?
You don't need a package for GA, probably easier to do it yourself, like this:
First, put the GA tracker id in Meteor.settings.public. (more info about that here)
Then, create a file for the client, probably in the lib folder, for example /client/lib/google_analytics.js and add the regular GA tracker to it:
// CLIENT
/*****************************************************************************/
/* Google Analytics */
/*****************************************************************************/
if (Meteor.settings.public.GaTrackingId) {
(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');
}
Last, create another file to track the page load. You can do this in a Meteor.startup() method, but you don't have to as the tracker code is in /lib which is loaded before everything else.
// CLIENT
if (Meteor.settings.public.GaTrackingId) {
ga('create', Meteor.settings.public.GaTrackingId, 'auto');
ga('send', 'pageview');
}
That's it. Now you can also do GA event tracking, etc. from anywhere in your app if you'd like to.