I got error when using the Google map
You have Included the Google Maps API multiple times on this page.
This may cause unexpected errors.
Google Maps API warning: SensorNotRequired
Google Maps API warning: NoApiKeys but I have a API keys
This is my footer tag
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/geofire/4.1.2/geofire.min.js">
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=">
</script>
Your API key is missing
It looks like you have not included the key in your Google maps script request.
Google has an official guide for how to set up everything
The take away in your case is that you included the script like so:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=">
</script>
You're missing the key parameter in the url. This is how google wants your request
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"
type="text/javascript"></script>
Notice the part where it says key=YOUR_API_KEY That's where you need to put your API key.
The API key looks like this: (not an actual key)
AIzaSyBMh448pWbvhyvsqY4OasYmam4ppD2CHPM
Your final link should look like this:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBMh448pWbvhyvsqY4OasYmam4ppD2CHPM"
type="text/javascript"></script>
More than one request
The other warning:
"You have Included the Google Maps API multiple times on this page"
indicates that your have tried to request Google maps API more than once on the same page. I don't see that in your example code. You may have another request someplace else like in the header. Don't use more than one per page.
Edit:
After looking at your page source I found this:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
This is the extra request that's causing the error where the API is requested multiple times.
Related
I am trying to get Google Optimize experiment data in JavaScript, by following these instructions. But I get no callback and I can't see anything happening in the debugger either.
The linked instructions use the gtag way of configuring GA, so I have set up gtag according to https://developers.google.com/gtagjs/devguide/snippet, and configured Optimize according to https://support.google.com/optimize/answer/7513085?hl=en with Method 1: Install Optimize with the global site tag (gtag.js).
I want to show the exact code I am using, but since I am doing it in React with Next.js Server Side Rendering, the original code has some extra stuff compared to plain HTML+JS. The source looks like this:
require("dotenv").config()
import React from "react"
import Document, { Head, Main, NextScript } from "next/document"
export default class extends Document {
render() {
return (
<html>
<Head>
<script async src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GA_TRACKING_ID}`}/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '${process.env.GA_TRACKING_ID}', { optimize_id: '${process.env.OPTIMIZE_ID}'});
console.log('GA setup done: ${process.env.GA_TRACKING_ID} + ${process.env.OPTIMIZE_ID}');
gtag('event', 'optimize.callback', {
name: '${process.env.EXPERIMENT_ID}',
callback: o => console.log(o)
});
`
}}
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</html>
)
}
}
This code produces a result page that starts Analytics and tracks a pageView just like it should, and when I do "RUN DIAGNOSTICS" in the Google Optimize console it opens the page, checks the JavaScript and reports:
Optimize is correctly installed
No major issues were detected while verifying the Optimize installation on this page.
I have also installed the Google Chrome Tag Assistant plug-in, and it reports that the Google Optimize tag is correctly installed.
I can see the following calls in the network log:
https://www.googletagmanager.com/gtag/js?id=UA-xxxxxx
https://www.google-analytics.com/analytics.js
https://www.google-analytics.com/gtm/js?id=GTM-xxxxxx&t=gtag_UA_xxxx&cid=nnn.nnn
I have also verified that the google_optimize global variable is created, and it has a .get() method. If I look (in the debugger network panel) at the http response of the https://www.google-analytics.com/gtm/js?... request I can actually see the Google Optimize experiments data with the correct Experiment embedded in the code.
So everything looks good, except for the fact that the optimize.callback event seems to be a complete no-op. It does not do anything at all. And I don't know how else to access the experiments data that I see in the http response in the debugger.
So I finally figured out what caused my struggles: I was running from a local NodeJS server, on the usual http://localhost:3000 url. Turns out Google Optimize will never trigger an experiment on http://localhost/... urls. The code wants a hostname part of the url that can be parsed according to a host.domain scheme.
In other words, there must be a dot in the hostname for Optimize to trigger an experiment.
For local testing, this can be fixed by creating a hostname alias such as localhost.domain for 127.0.0.1, and accessing the web page using this alias.
I found a way, which can achieve start google optimize experiment with localhost.
So, just use next settings for google optimize experiment and it will start successfully.
How can you add Application insights end-user user analytics to DocFx to track the usage of every documentation page?
The Application Insights documentation states you need to insert the JavaScript snippet listed below immediately before the closing tag, but I'm not sure if this is possible in DocFx or the best way to accomplish.
Would you need a postprocessor, or could you use a custom template?
<!--
To collect end-user usage analytics about your application,
insert the following script into each page you want to track.
Place this code immediately before the closing </head> tag,
and before any other scripts. Your first data will appear
automatically in just a few seconds.
-->
<script type="text/javascript">
var appInsights=window.appInsights||function(config){
function i(config){t[config]=function(){var
i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{t.cookie=u.cookie}catch(p){}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}),t
}({
instrumentationKey:"###-###-###-##"
});
window.appInsights=appInsights;
appInsights.trackPageView();
</script>
No PostProcessor is needed. You can achieve this by customizing the template. More information can be found in official tutorial or this question. You can add your code in partials/head.tmpl.partial. It will affect all the generated page.
I am trying to run Google Map on a WordPress site. The code is running perfectly on this JSFIDDLE but when I take it to WordPress I am getting this error
Google Maps API warning: SensorNotRequired:
https://developers.google.com/maps/documentation/javascript/error-messages
I also tried this code
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
but the result is same.
Finally I tried to get a key from API and use it
<script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&callback=initMap"
async defer></script>
and now I am getting this error
Uncaught TypeError: window.initMap is not a function
can you please let me know why this is happening and how I can fix it?
Instead of:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
Try:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?v=3"></script>
From the Google Maps API documentation:
The sensor parameter is no longer required for the Google Maps
JavaScript API. It won't prevent the Google Maps JavaScript API from
working correctly, but we recommend that you remove the sensor
parameter from the script element.
under some conditions (that only god or google knows), this is not sufficient to provide the js tag...
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
... in order to load the Google V3 API. I must provide in these cases the following tag that loads the corresponding main.js:
<script type="text/javascript" src=" http://maps.gstatic.com/intl/pt_br/mapfiles/api-3/8/7/main.js"></script>
Because this file doesn't load automatically from the first script.
Do someone already experienced the same behaviour?
Probably that's because you don't specify api-version in script tag. This works fine for me:
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"></script>
I have been using Urchin 6 but have just started to use Google Analytics also. I am also using Google Search Appliance for site search.
Search is on a subdomain i.e. www.search.mysite.com
The problem is that Google Analytics is tracking site search as a self-referral. After a lot of reading online I have ended up with the GA code configuration below which should be picking up the search subdomain but it isn’t. Can anyone see anything incorrect about my configuration?
- E.g. is the GATC request process order correct
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-1']);
_gaq.push(['_setLocalRemoteServerMode']);
_gaq.push(['_setLocalGifPath', '/__utm.gif']);
_gaq.push(['_setDomainName', 'mysite.com]);
_gaq.push(['_addIgnoredRef', 'mysite.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>
I have a suspicion that the issue could lie with the configuration of GA on Google Search Appliance. When you add GA it just asks for the UA code on the XSLT and you send up with the script below on each search page:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">
<!--
_uacct = "UA-xxxxxxx-1";
urchinTracker();
//--></script>
Could this be the problem or does this code need to change in the XSLT or maybe not?
Any help would be appreciated.
Thanks
I don't have a complete answer for you, as I'm trying to work out some glitches myself. But maybe this will help suggest approaches.
I'm using version 6.8.0.G.30 of the search appliance.
I can insert my Google Analytics account number in the Analytics Account field under the "Global Attributes" section of the Page Layout Helper for the desired Appliance Front End.
That GUI approach has the effect of inserting the account number into the XSLT for that Front End:
<!-- *** analytics information *** -->
<xsl:variable name="analytics_account">UA-1234567-1</xsl:variable>
When the transformation is processed and the page is rendered, if a value is found for the account, then this JavaScript is generated in the search results page:
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script><script type="text/javascript">
var pageTracker = _gat._getTracker("UA-1234567-1");
pageTracker._trackPageview();
</script>
As an alternative to using the Page Layout Helper, you can "Edit underlying XSLT code" to manually edit the stylesheet and insert the analytics account.
The Google Analytics code produced by the default XSLT may not be what you want (probably isn't based on your post). For example, the snippet above is the synchronous version.
So, you'll probably want to edit the XSLT anyway to modify the snippet. I wanted to use the asynchronous snippet, so I changed the template named "analytics" used in the XSLT (that specifies to not customize):
<!-- **********************************************************************
Analytics script (do not customize)
********************************************************************** -->
<xsl:template name="analytics">
<xsl:if test="string-length($analytics_account) != 0">
<script type="text/javascript" src="{$analytics_script_url}"></script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("<xsl:value-of select='$analytics_account'/>");
pageTracker._trackPageview();
</script>
</xsl:if>
</xsl:template>
That template is where the account information you've previously entered in the XSLT (via GUI or XSLT) gets substituted in. It's called at various locations in the Front End XSLT.
It's also possible to change the URL for the analytics script (you see that variable used in the "analytics" template).
What I did was to substitute the "analytics" template above with my own asynchronous version. So now when I look at the rendered search results, I see the async snippet there.
In my _setDomainName method, I have a leading period before the domain: .mysite.com which is consistent with the other Google Analytics-enabled pages on the rest of our site.
The "best practice" for this seems to be an area of some discussion: http://www.roirevolution.com/blog/2011/01/google_analytics_subdomain_tracking.php
Many of the comments on that post refer to self-referrals.
On the appliance search results page, the Google Analytics snippet appears immediately following the <body> tag.
The discussion of where to locate the asynchronous snippet (or "parts" if it's being split) has been raised in repeated forum posts:
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=71ba44443f0bfbc3&hl=en
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=22ac794d8f26a2f4&hl=en
This has been a pretty good reference for me on the asynchronous snippet:
Asynchronous Tracking Usage Guide:
http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html
Moving the snippet to <head> would take me some thinking and a more thorough look at the XSLT (and probably tweaking that would be jeopardized with future appliance versions and potential XSLT changes)
In terms of debugging Analytics, I've started to focus on investigating the values of GA-specific cookies and the __utm.gif using Firebug and other similar browser tools.
This post:
http://blog.vkistudios.com/index.cfm/2008/12/17/Slicing-and-Dicing-Cookies--Part-2--Body-Parts
as well as its followup, and other pages at that site have really helped suggest an approach to troubleshooting.