analytics.js URL Calls - javascript

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

Related

Track outbound Google Analytics link in new analytics.js

I have new analytics.js on a new webpage. This webpage has to be linked analytically to the existing webpages, managed by other people.
They sent me a line of code to do it:
_gaq.push(['_link', $(this).attr('href')]);
This is the old version of the analytics. I understand, that the same thing in new analytics can be accomplished using:
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
To where on the second I should put '_link' and $(this).attr('href') parameters?
There is not much documentation on the Google website. I have enabled official linker plugin, but they say, that this is not enough.
Edit: Bit of js after loading analytics.js looks like this:
ga('create', 'UA-12312312-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['friendlydomain.com'] );
ga('set', {page: window.location.href});
ga('send', 'pageview');
Where UA-12312312-1 is their tracking id. I can see, that ga parameter is added to the links going towards friendlydomain.com
This line of code:
_gaq.push(['_link', $(this).attr('href')]);
is not for outbound link tracking, it's the linker for Cross Domain tracking (see the documentation for the old ga.js library).
To accomplish the same with analytics.js it would be best to use the autolink plugin. This appends the client id to outgoing links; the linked pages must have linking enabled in the configuration to receive the parameter from the url and set it as client id when the tracker is created. GA will then use the client id to merge the sessions on both domains into one.
This will work only if both pages run analytics.js. Also you need to set both domains in the referral exclusion list in the property settings.
analytics.js is fairly flexible, so it mostly depends on how you want to view the data on the GA site.
One possible solution would be...
ga('send', 'event', 'link', 'click', $(this).attr('href'));
Also, the docs are fairly comprehensive. You might consider re-reading them here: https://developers.google.com/analytics/devguides/collection/analyticsjs/events#event_fields

Setup Google Analytics with Meteor App: Tracking not Installed Error

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.

Cross domain tracking in Google Analytics

I am first time posting something here...
Issue:
We have moved to Universal Analytics few month back and since then form submission conversion attribution is broken. Almost all conversions (form submission) are attributed to direct traffic. Actually we have our confirmation page on third domain (now.eloqua.com) but it has the same code as we have on the website. But I guess due to different domains, cookies are getting drop in transition from main website to the confirmation page as analytics.js does not set up _utm cookies
Possible Solution, is I guess using Cross Domain Auto Linking (auto link plugin), We have implemented below code on both main website page and Thank you page (eloqua.com).. but issue still persists. Can somebody suggest what wrong I am doing here...
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-xxxxxxx-X', 'auto',{'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['eloqua.com']);
ga('send', 'pageview')
As you are saying that your conversions are form submission you might have to add another parameter to the call to the autolinker plugin (this is as per documentation, I have not tested this):
Cross Domain Auto Linking for Forms
Universal Analytics also includes the ability cross domain link
elements automatically. ga('linker:autoLink', ['destination.com',
'dest3.com'], false, true);
Where the third parameter (false) tell the autolinker to not use the anchor/hash and the fourth parameter tells it to auto-decorate form action urls (else only links get decorated), so this is what you need. You should see a _ga parameter appended to the urls on arrival at the other domain if this is working correctly.
Plus I'm reasonably sure that you need to add both domains to your referral exclusion list.

Google Analytics Real-Time not showing results

The following script is not generating activity when cross-checked in Google Analytics : Real-Time section : Content section --
<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-475021xx-x', 'auto');
ga('send', 'pageview');
</script>
where xx-x masks the real account code.
The script is placed just before </head>
We have upgraded our account to Universal Analytics. Google tells us that this is the script to use; directly copied and pasted here (with the masked account code).
On the Google Analytics page, the test page is loaded as an ACTIVE PAGE. I click links on the test page to trigger ga.
Is there an error in this script? For example, I see on other Stackoverflow posts that 'auto' is replaced with the real domain. But I don't see Google instructions to make that substitution.
Am I doing something else wrong?
I did the same thing as you back then.
Mine started showing data in about 12-24 hours after I put the Google Analytics code.
I suggest waiting for another day then checking if data comes up.
Given that this answer can only be verified until we wait for a certain amount of time, please hold off setting this as the correct answer until then.
For me, the issue was a dunce move. I have the Google Analytics Opt-out Add-on for Chrome enabled.
What I had to do was go to chrome://extensions/, scroll down to the Extension "Google Analytics Opt-out Add-on (by Google)" and uncheck the box that says, "Enable".
I hope this helps someone.
You can check the health of your tag using Google tag assistant, and also check with developer tools whether you can see data being sent to your GA account. Also look in your account under Property > Tracking Info > Tracking Code for the status of your tracking code. But if you are not seeing Real Time data then something could be wrong.
The third parameter in the 'create' method sets the cookie domain. It is optional and with 'auto', it sets the cookie domain to the highest domain level possible. Without it, the cookie domain will be set to the website domain without the www. prefix.
Here is what my issue was. I'm using google analytics with wordpress. I tried configuring google analytics for my website using plugin called Google Analytics Dashboard for WP (GADWP). This plugin generated a google analytics snippet that looks similarly to the one described in the question:
<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-475021xx-x', 'auto');
ga('send', 'pageview');
</script>
However, in Google Analytics console, the suggested snippet looked like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-110984887-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-475021xx-x');
</script>
It looks like this gtag.js is a new format for the google analytics snippet. So I disabled that wordpress plugin and I manually added the script suggested by Google Analytics to the page.
I have recently fixed the same issue. Please login to your admin dashboard and check the filters.
What I did was to make sure my valid host name filter was the correct one.
If you have copied the custom dashboard from another project or if you had an error in the filter then this would be worth your time to check out.
I have placed the value "domain.com" in the included host names filter.
Let me know if this fixed the issue for you.

AJAX based contact form 7 event tracking for new Google analyics code

So, we have a couple of wordpress websites. For one of the them the analytics code is of an older version (gaq.push) format.
For this particular website, we have the tracking set up just fine and Google analytics goals are properly working. In the "additional setting" section of contact form 7 (via WP-Admin), we are using:
on_sent_ok: "_gaq.push(['_trackPageview', '/rfp-form-thank-you']);
However, for the other one, the newer version shows up which is ga.js based and the format looks like this:
<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-4248211-9', 'www.website.com');
ga('send', 'pageview');*
</script>
Now, the issue is: we tried following the method as we did for the other one but that doesn't seem to work. It may be because the analytics code is different this time.
How can we set up proper form submission event capture so that goals can be fulfilled in Google Analytics?
The method used in the question is in fact a virtual pageview, not an event. The correct syntax is as follows for virtual pageviews under the new Universal Analytics library:
ga('send', 'pageview', '/enter-new-pageview-here');
For CF7, you'd use the above syntax and then enter "/enter-new-pageview-here" as a destination URL goal, which is what I believe the qustioner is trying to achieve.
Reference
Syntax is different (and your example is in fact analytics.js based, not ga.js):
ga('send', 'event', 'category', 'action', 'label', value);
Documentation

Categories