I'm having trouble getting an OnClick event to send back to Google(Universal) Analytics.
Here's the line in question:
<a href= “link-to-asset-goes-here” onclick="ga(‘send’, ‘event’, ‘Button’, ‘Click’, ‘AllVisits_Free’, {‘NonInteraction’: 1});”>
When I inspect with Chrome Dev tools, I'm seeing this error: "Uncaught SyntaxError: Invalid or unexpected token"
When looking through other questions, I found this one:java - OnClick error
Could it possibly be just escaping all the strings then? Like so:
<a href= “link-to-asset-goes-here” onclick="ga(\‘send’\, \‘event’\, \‘Button’\, \‘Click’\, \‘AllVisits_Free’\, {\‘NonInteraction’\: 1});”>
Would that cause any issues with the NonInteraction part of the code?
Unfortunately I don't have access to test this live, and have to send each code revision over to the client each time, or I could just test different variations of code a lot easier.
And just for reference, we're using the newest version of GA(Universal) analytics tracking code. When looking at the Real Time reports in GA, it's registering that I'm on the page, but events are not firing when clicking the link.
Thanks!
If that it the exact code format you are using, then try using straight quotes rather than the smart quotes:
<a href= "link-to-asset-goes-here" onclick="ga('send', 'event', 'Button', 'Click', 'AllVisits_Free', {'NonInteraction': 1});">
....Something with smart quotes not playing well with JavaScript.
I was getting the same error while using this onClick code.
Straight codes worked for me.
The mistake which I made was copying the code snippet from the website. Enter the quotes directly from the keyboard and it will work great!
Also for quick debugging, use the GA Debugger, it helped me resolve the error quickly.
Related
I have added Google Sign In button to a web page according the following description - https://developers.google.com/identity/gsi/web/guides/display-button
Unfortunatelly the button is displayed but it does not work.
In the console I see an error:
[GSI_LOGGER]: Parameter client_id is not set correctly.
that happens when the following script is being loaded:
https://accounts.google.com/gsi/button
Could anyone of you experienced the same problem?
In case someone has encountered the same problems - I found a root cause - prototype (https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js) script somehow interfered with google sign in button.
Once I removed it, the google sign in button started working properly.
In Angulartics2, how do you pass the event label to Google Analytics?
Currently I have this code:
<a type="button" [routerLink]="['SecondPage']" angulartics2On="click" angularticsCategory="Click" angularticsEvent="Homepage">Click me</a>
When using the Analytics debugger for Chrome, it shows an event being fired which passes category and action. Looking at the code in GitHub makes it look like it is possible to supply a label, but I'm not clear what attribute needs adding to the anchor tag? angularticsLabel doesn't appear to have any effect.
The other answer provides the correct method, but it is also necessary to wrap the Object literal in parenthesis due to an eval in the code:
angularticsProperties="({label: 'some label'})"
Try to use the angularticsProperties parameter
angularticsProperties="{label: 'some label'}"
cf. https://github.com/angulartics/angulartics2/issues/22
The new version now (1.1.9) is:
[angularticsProperties]="{label: 'YourLabel'}"
I just udpated README file by a PR here.
I am installing google analytics on some links
javascript:_gaq.push(['_trackEvent', 'category', 'browse', '/hair'])
here's how the link is
<a onclick="javascript:_gaq.push(['_trackEvent', 'category', 'browse', '/hair'])" href="/hair"><i class="icon-"></i>Hair (162)</a>
if I click on the link the push event is not getting recorded.
If I hit the same code from the console then the event is recorded.
NOTE: on Firefox the event are getting recorded properly. So far this only happens on Chrome! :S
Any ideas?
You need the "javascript:" bit only if you put the js in the href attribute (as a protocol designation of sorts). For a click event the javascript method itself will suffice, so your example should look:
<a onclick="_gaq.push(['_trackEvent', 'category', 'browse', '/hair'])" href="/hair"><i class="icon-"></i>Hair (162)</a>
I'm taking a quite educated guess here that FF is more forgiving with the irregular syntax than Chrome. Maybe you can look at the Chrome developer console if this throws an error (or simply fix it and see if things improve).
My Google Apps Script web app stopped working.
Whenever I click on any element that has onclick property I am getting the following error message:
[11:27:44.243] cannot use the given object as a weak map key
Is there any workaround?
How can I get user's response without onclick event?
My code:
Note that I am trying to add onclick event using both ways, programmatically in JavaScript and by using HTML.
var by = document.getElementById("yes");
by.addEventListener('click', submitResponse,false);
This problem was submitted as google apps script issues:
http://code.google.com/p/google-apps-script-issues/issues/detail?id=2625
thanks for help!
Since this is an acknowledged issue with Apps Script, there isn't much that can be provided here in Stack Overflow.
Here is a bit more context, this was broken and now fixed in Caja. This fix should be reflected in Apps Script in a few days.
I've installed a Like button on my blog, as well as the Facebook send button.
When I click "Send", the popout comes out and appears nicely with a prompt on who to send the post to.
But, when you click "Like", no popout comes. It's not the "overflow:visible" problem, because the Send popout works. Very confusing and odd, I think...
This is the code I'm using:
<div style="overflow:visible;" class="fb-like" data-href="http://liamgetreu.com" data-send="true" data-width="450" data-show-faces="true" data-font="lucida grande"></div>
Any ideas? Thanks.
I checked out your blog and it looks like there is an iframe being generated for the pop-out, but that pop-out is not being filled in by Facebook. There is a javascript error that is the probably cause of the issue.
uncaught exception: Error: Permission denied for <http://www.facebook.com>
to get property Proxy.InstallTrigger
https://plus.google.com/_/apps-static/_/js/widget/gcm_ppb,
googleapis_client,plusone/rt=j/ver=VRKLmt4S1dg.en_US./sv=1
/am=!itqi7GDL5S6I4GqN1g/d=1/ Line 116
To find out what javascript is colliding with that Facebook one to cause the error. I would suggest striping everything off that page one thing at a time until the Facebook script can run without error. This will tell you what item (or combination of items) was interfering.
Happy troubleshooting! Let us know what you find.