I am making an app and I want to get analytics from the users. I got this code from google developer link i am able to build it correctlyand page load i am getting alert("called"). But I'm still seeing no hits in Google Analytics website itself. Can anyone help in figuring out the problem?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-52594810-1']);
// _gaq.push(['_trackEvent', 'Videos', 'Play', 'Gone With the Wind']);
_gaq.push(['_trackPageview', 'Videos', 'Play', 'Gone With the Wind']);
(function () {
alert("called");
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
Related
I am trying to determine if my google analytics are being reported twice based on the javascript below in my page. I dont have to have the second script in there to make it work as far as I know, but I am trying to determine if page views/sessions were being recorded twice based off of this configuration. If anyone can provide a test I can do to find this out myself i would appreciate that as well.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-3']);
_gaq.push(['_setDomainName', 'mywebsite.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js"></script>
as the title says, how do I track a website with Google Analystics from two different accounts?
I made some research about this topic and found alot of old posts which were saying that you should include the different tracking codes at each side. But this can't be the best way, right?
Is it possible to do something like this?
Old Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
New Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_setAccount', 'UA-xxxxxxxx-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Thanks in advance Jack
Yes, its possible without updating any old code. you have to add other account to primary account:
Click Admin at the top of Google Analytic page.
To show three column Account, PROPERTY, VIEW.
Select USER MANAGEMENT from Account, PROPERTY, VIEW base on access permission.
Enter Email address and assign roll.
check your secondary email address website tracking same as primary email address.
You can track the same page on two different GA accounts using this code:
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-12345678-1'], // First account
['_trackPageview'],
['b._setAccount', 'UA-87654321-1'], // Second account
['b._trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
This has always worked for us.
I am using Google analytics to track an event when a button is clicked. Please find below my piece of code responsible for that.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#accountNumber']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<button id="button-submit" onclick="_gaq.push(['_trackEvent', 'CoreSiteCulture UK Submit', 'US Home', 'example.com']);">Save</button>
The the events are sent but they do not appear in Google Analytics events.
Does anyone knows what might be wrong?
EDIT:
I am using the GA Debugger for debugging and it says Tracking beacon sent.
Maybe the problem is not in production.
Please check:
http://oapp.com.ar/stack/index.html
The problem is that analytics can not be tested in local environment
For local testing, you need to add this
ga('create', 'UA-XXXX-Y', {
'cookieDomain': 'none'
});
Here is the link for reference.
I have two Google analytic s event in one page. I only want one Google analytic event. Is there anyway i can remove one so when i open that page, only one Google analytic can be seen.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
and,
<script type=text/java-script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans','7000004','380194','99.99','7.27','20','Richfield','MN','US']);
_gaq.push(['_addItem','7000004','38361','Power Shovel (38361)','','99.99','1']);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + 'Google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
I want second one to delete.
Thanks a lot
If I've understood your question correctly, this should be really easy to resolve.
It looks like you've got two identical blocks calling Google Analytics (on the account UA-31277529-1), the first is just the vanilla add-to-the-page code supplied by Google.
The second block includes the same initialization but also pushes a couple of additional pieces of information to Analytics (eCommerce tracking?). Essentially, you've got redundancy in the set-up and page tracking because of that first block.
So, I'm assuming that you want to both:
track page visitors via Analytics;
and track the additional eCommerce attributes you're pushing.
Then, all you need to do is remove the first code block and use only the second one:
<script type=text/java-script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31277529-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans','7000004','380194','99.99','7.27','20','Richfield','MN','US']);
_gaq.push(['_addItem','7000004','38361','Power Shovel (38361)','','99.99','1']);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + 'Google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
This will still track your page views, but will also track your eCommerce objects, which should all occur in one, single 'fire'.
I would like to count my downloads through Google Analytics events. Unfortunately nothing shows up in my statistics.
This is the GA code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
And my link:
Download
Why it is not working?
According to Google Documentations :
<a href="http://www.example.com/files/map.pdf" onClick="javascript: _gaq.push(['_trackPageview', '/downloads/map']);">
To verify that _trackPageview is being called correctly, you can check your Top Content report 24-48 hours after the updated tracking code has been executed. You should be able to see the assigned pagename in your report.