How to get Google Analytics tracking code active in Codeigniter? - codeigniter

I am using Codeigniter to create a web site. The problem is I've put the tracking code from Google Analytics in my website, but no matter where I put it (header or footer), and in what section of my website, the result is the same: when I go to the GA to verify that Google is receiving the data, it says it's not.
The tracking code GA gave me:
<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-65860566-1', 'auto');
ga('send', 'pageview');
</script>

You could read this to ensure you've put your code in the right place:
https://support.google.com/analytics/answer/1008080?hl=en

Related

Can't get Google Calendar to populate FullCalendar

I'm new to programming so please excuse the improper terminology, but I was able to get a basic FullCalendar added to my website and would like to populate the calendar based on one of my public Google Calendars. I followed the steps on FullCalendar's website for setting up Google Calendar but I still just see a blank calendar, even though there are events on the public Google Calendar. The only step I was unsure of when setting things up was the Authorized JavaScript Origins section of setting up the Google API. I am using a GitHub pages site and it would not accept the full path name for my site so I just put the main hub portion (https://username.github.io) in this Authorized JavaScript Origins field. Is this incorrect? What needs to go in this path if I am using the FullCalendar on a site with the following type of URL: https://stephmorgan.github.io/repository/ ?
<head>
<link rel="stylesheet" href="fullcalendar/fullcalendar.css" />
<script src="lib/jquery.min.js"></script>
<script src="lib/moment.min.js"></script>
<script src="fullcalendar/fullcalendar.js"></script>
<script src="fullcalendar/gcal.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#calendar").fullCalendar({
googleCalendarApiKey: "<API-KEY>",
events: {
googleCalendarId: "b3eki2m39g1lcfcq3nnl1vb9lo#group.calendar.google.com"
className: "gcal-event"
}
});
});
</script>
</head>
<body>
<div id="calendar"></div>
</body>
There are several problems:
1) googleCalendarId: "Calendar ID: b3eki2m39g1lcfcq3nnl1vb9lo#group.calendar.google.com" should be googleCalendarId: "b3eki2m39g1lcfcq3nnl1vb9lo#group.calendar.google.com", as per the example at https://fullcalendar.io/docs/google_calendar. It thinks "Calendar ID: " is part of the ID, which obviously it isn't, and Google won't recognise it.
2) The same issue with the API Key - remove the < and > from the ends of the string.
3) It sounds like you chose the wrong kind of credentials - the API key config does not contain a section from JavaScript origins etc. You must choose to create an API Key (sometimes called a Browser Key), and not Oauth Client ID or Service Account.

Google analytics not counting pages loaded with AJAX, but they apear in real time information

I recently started using AJAX for loading content into the front page. I searched this problem and I found that i had to add a little piece of code.
ga('set', 'page', pagePath);//pagePath = consulted URL
ga('send', 'pageview');
Now, the problem is that, even though i can see in the real time informacion when another page's content is loaded into the front page, those visits are not being loged.
This is the analytics code I'm using
<!-- 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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
Is there something I'm missing? Thanks

Local host sandbox - Google Universal analytics code is not working

Note: I tried the existing answers and they are not working
In my local host Magento setup, Google Universal analytics code is not working. I am not able to see the hits in my account. Can anyone tell me what could be the issue ? Below is the code
<!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
(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', '<My Account-Id>', {'cookieDomain':'none'});
ga('send', 'pageview');
//]]>
</script>
<!-- END GOOGLE UNIVERSAL ANALYTICS CODE -->

Running Google Analytics under play 2.2.1 on heroku

I have created a test page on heroku: Test Page
I have also added 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-xxxxxxxx-x', 'shrouded-bastion-7859.herokuapp.com');
ga('send', 'pageview');
</script>
As you can see in my site code, I have inserted this script in my plain html page.
In the play project I have implemented the sites as static html pages in the public folder.
However, on the Google analytics board it says that:
Status: Tracking Not Installed
What am I doing wrong? I really appreciate your answer!

Google analytics doesn't work on my heroku app

I run a python web app on heroku platform,
using heroku sub domain like: example.herokuapp.com
and I add google analytics js code to my page:
(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-xxxxxxxx-x', 'herokuapp.com');
ga('send', 'pageview');
I have insert this script over 12 hours, but when I enter my ga account admin panel, it tell me:
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.
however, I still can see some PV on the report panel
Does the ga work or not? How can I solve this problem? If I use a top level domain could solve this problem?
Two things regarding your ga.create() call:
1) The third parameter ("herokuapp.com" in your case) is supposed to be a Javascript object, not a plain string. Did you actually mean {'cookieDomain': 'herokuapp.com'}?
2) If you did... then it should be example.herokuapp.com -- you can't set a cookie on all of herokuapp.com.
I've found that the new universal analytics is actually a little slow to kick in within the interface. The old Google analytics used to be like this and could take a day to work.
I have set up universal analytics on 6 sites now, I could see the calls being made to google but it took a day for data to show.
Have you used any debugging tools available.
For Firefox httpfox is a great tool, once installed select start and filter by 'collect' this will display analytics calls if they are working.
In chrome there are 2 good extensions, tag assistant and ga debug both by Google. Both of these can help identify implementation issues.
Hope this helps
John
Credit: https://towardsdatascience.com/advancing-to-professional-dashboard-with-python-using-dash-and-plotly-1e8e5aa4c668#cf77
Try this
import dash
app = dash.Dash(__name__)
app.index_string = """<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131327483-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-131327483-1');
</script>
{%metas%}
<title>{%title%}</title>
{%favicon%}
{%css%}
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
</body>
</html>"""

Resources