I am trying to get email enquiries submitted through the website to show up in Analytics as a tracked event.
This client has multiple domains so we are tracking which email enquiry came from which site.
This is the code created so far. (please note we use coldfusion to pull from our CMS system)
<!-- Analytics Tracking Code-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<cfif isdefined ("getsite.contact") AND getsite.contact NEQ "">#getsite.contact#<cfelse>UA-109409-1</cfif>']);
_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>
<!--Email Tracking Code in Analytics -->
<script type="text/javascript">
jQuery(document).ready(function($){
$('form').submit(function(event){
//if analytics object exists
if(window._gat){
event.preventDefault();
optinForm = this;
_gaq.push(['_set','hitCallback', function(){
optinForm.submit();
}]);
_gaq.push(['_trackEvent', 'Email Enquiry', 'Form Submitted', '#getsite.domain#']);
}
//if no analytics object, service as normal
});
});
</script>
Any assistance would be great.
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>
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'.
Below is the code to track the how many guest visited my page?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18841631-1']);
_gaq.push(['_setCustomVar',1,'Status','Logged-in',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>
How to track the user after login to the website?
To track the user after login what all are the steps have to follow..plese guide me...
The best way for user tracking after his login is session . Just create and maintain session variables according to your need when user successfully signed in.
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.