I have set up a form through contact form 7 in a website. I have added Google analytics tracking code to set up a event goal on form submission. The event seems to get monitored on real time basics as in every form submission is triggering a event under the events tab. But the data seems to not get recorded as a goal under the conversion tab. Can someone find a solution to this.
I have used the following tracking 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');
analytics.com/analytics.js','ga');
ga('create', 'UA-18282623-2', 'auto');
ga('send', 'pageview');
</script>
and have set this code under the additional setting bar of contact form 7 to trigger the goal event:
on_sent_ok: "ga('send', 'event', 'contact-form', 'click', 'submit form',1);"
where I have set
contact-form = Category
Action = click
Label = submit form
Value = 1
I have also tried with this code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18282623-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>
along with:
on_sent_ok: "_gaq.push(['_trackEvent', 'contact-form', 'click', 'submit form']);"
Nothing seems to work. Please help
enter image description here
enter image description here
Your goal configuration includes a value greater than 1, but your event is sending a value exactly equal to 1. You will either need to adjust your goal configuration to convert when the value is equal to one or send a value for your event greater than one.
Related
I am trying to implement google analytics and I'm running into a problem where the tracking beacons are being sent, and the conversion goals are not being recorded. What I'm trying to do is show a modal and record whether the modal is submitted or closed. The goal setup I'm using is this:
Category: SignUp
Action: Newsletter
Label: Manual
Value: GreaterThan 1
These are the two things I've tried for the analytics code:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'MyAccountNumber']);
_gaq.push(['_setDomainName', 'MyDomainName']);
_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);
})();
function _trackEvent(category, action, label, value, nonInteraction){
nonInteraction = nonInteraction || false;
_gaq.push(['_trackEvent', category, action, label, parseInt(value), nonInteraction]);
};
And this
(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', 'MyAccountNumber', 'auto');
ga('send', 'pageview');
function _trackEvent(category, action, label, value){
ga('send', 'event', category, action, label, value);
};
I am calling _track event as such:
_trackEvent('SignUp', 'Newsletter', label, 0);
$('#modalSubmit').click(function() {
_trackEvent('SignUp', 'Newsletter', 'Manual', 1);
});
As I previously said, the tracking beacons are being sent, but there is no data showing up in the Reporting section. The dates for the report are set to yesterday through tomorrow. Also, if I'm not handling the abandonment rate correctly, what is the correct way to handle this? Thanks in advance!
You should only use the universal tracker. It's more accurate.
Make sure you're receiving data then troubleshoot events accordingly. You can check the tracking code status in the Admin section of GA: https://support.google.com/analytics/answer/1008083?hl=en
Google Analytics generally updates your reports every 24 hours, so it can take at least that long for data to appear in your account after you first install the tracking code: https://support.google.com/analytics/answer/1009219?hl=en
I am receiving a 404 error from my Google Analytics tracking code. The following is the code I am currently using in the footer of my page:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'ssl' : 'www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
The 404 error appears to be caused by: /p/__utm.gif
I was using the same JS code from this question: Google Analytics and the __utm.gif file. However, that didn't work with my last report from Goolge.
Is there other way to do it?
You are using an older tracking snippet from GA. You should update to the latest version as it should solve your problem. You should also ensure that this tracking code is on all of your pages on your site. The latest code snippet looks more like the following:
<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-XXXXXXX-X', 'auto');
ga('send', 'pageview');
</script>
You can get a formatted snippet for your site by:
logging into GA (Google Analytics)
Going to the admin UI by selecting the "Admin" tab at the top of the interface
If you have multiple accounts, ensure you have the correct account selected on the left (Account) column of this screen
Select the site you need the snippet for in the center (Property) column.
Select "Tracking Info" and then "Tracking Code" from the middle column.
The column should animate to the left and a new bit should appear that contains your tracking code formatted and completed for your site.
Copy and paste this into every page on your site.
I've got the following code in the head which isn't tracking outbound links:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxxx-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>
<script>
/**
* Function that tracks a click on an outbound link in Google Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label.
*/
var trackOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
function () {
document.location = url;
}
});
}
</script>
And have added the event tracking on outbound links as stated on the analytics site:
onclick="trackOutboundLink('/WEBSITE/www.something.com')
What am I doing wrong? No outbound links are being tracked.
Update - changed the tracking code to universal; which event outbound tracking do I use?
<!-- Google Analytics -->
<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-xxxx-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
uname12, the issue is that you are mixing "old" Google Analytics tracking code and "new" Universal Analytics tracking code syntax.
UPDATE to my original answer to reflect changes to original question:
I would try using the correct address, so instead of:
onclick="trackOutboundLink('/WEBSITE/www.something.com')
try this:
onclick="trackOutboundLink('http://www.something.com')
ORIGINAL answer:
That's the reason why the tracking doesn't work. Here is the correct documentation for event tracking (always look GA.js).
If you change your code to something like this:
var trackOutboundLink = function(url) {
_gaq.push(['_trackEvent', 'Outbound', 'Click', this.href]);
setTimeout('document.location = "' + this.href + '"', 100);
return false;
}
That should do the trick.
Hope this helps :-)
In my property's Tracking Code section I see this message:
Status: Tracking Not Installed Last checked: Oct ...
The Google Analytics tracking code has not been detected on your website's home
page. For Analytics to function, you or your web administrator must
add the code to each page of your website.
The tracking code shown to be copy/pasted is 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-XXXXXXx', 'example.com');
ga('send', 'pageview');
</script>
There's a learn more button and when I click it it takes me to here which shows the asynchronous code, which is something like this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-Y']);
_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>
Is this the current/latest version of the GA code? Why is the dashboard (i.e. the Tracking Code section) is not showing this by default? Is there a way to customize the Google Analytics to show this code in the Tracking Code section, prepared for my property (website)?
What you are seeing first is the latest version of Google Analytics known as Universal Analytics. As per Google recommendation , use that for all your new analytics properties. This is identified by the analytics.js library in the tracking code
The second one is an earlier version of Google Analytics based on ga.js library.
Use the first version of tracking code given by GA and follow this tutorial based on analytics.js to debug your code.
I'm trying to use this code to track an event in Google Analytics
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
This seems to be meant to be use with the GA.js Analytics "package", however I'm using the Analytics.js
Like this
(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');
Is there a way I can do even tracking with this code only ?
Or do I have to use
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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);
})();
Do I need both of these codes?
Or is there some different way using only Analytics.js
Thanks in advance
**EDIT:
Indeed I probably didn't explain what I want, it might not even possible.
I want to work with Funnels on Events, and I want to use _trackEvent (that's what I thought it would do) to mark a user as having Entered the Funnel, if the event is send then we will have the normal funnel.
So if 10 users enter the page and 1 clicks on the button, I would have 10 events on the Funnel with 1 success
analytics.js will report to GA same as the old code, but it has different syntax, so you can't use _trackEvent.
Here is a link to the basic on-page syntax with analytics.js, and here is a link for event tracking with analytics.js
<!-- Google Analytics -->
<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-XXXX-Y'); // GA account ID goes here
ga('send', {
'hitType': 'event', // Required.
'eventCategory': 'category', // Required.
'eventAction': 'action', // Required.
'eventLabel': 'opt_label',
'eventValue': opt_value,
'nonInteraction': opt_noninteraction
});
</script>
<!-- End Google Analytics -->