I am trying to add the Google Analytics Embed API to a tabbed Reports page in my MVC 5 Web App. I am using these instructions.
https://developers.google.com/analytics/devguides/reporting/embed/v1/getting-started
I added the main function to the $(document).ready(function (), which is in an external Javascript file that gets called in the main Index View for the tabbed Reports page. I then created a PartialView called _GooglePartial. The PartialView contains the rest of the code along with the other Javascript code.
I've set alerts all throughout the code. The first time the entire page loads and everything gets called.
I get the Google login button and I can login. After log in, it displays the email of the logged in user. I now notice that the Javascript code does not call my Step 4 alert as shown below.
Step 4: Create the view selector. alert('Step 4');
Here is how I am calling the _GooglePartial View. This is in my external Javascript file.
getGoogleData: function () {
var url = '/Reports/GetGoogleData';
myapp.GetNoParam(
url,
function (result) {
$('div#filter-content').html(result);
}
);
},
I had to use this to get my Google Map code to work correctly in another Page/View, so I believe I have to do something similar with platform.js, but I have no idea how to make it work.
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&' +
'callback=initMap' + '&key=SOMEKEY';
document.body.appendChild(script);
}
window.onload = loadScript;
Does anyone know how to get this to work? I'm trying to display Google Analytics (their own) to my user's in a multi-tenant application. Perhaps there is a better way to do this in an MVC 5 App.
Any help is much appreciated! Thanks!