Hi there. Is there a way that I can add Javascript to my Wix pages? The Javascript I have will be used to store parameters in my tracking template urls, and then pass them in links leading away from my site.
The first javascript on the landing page will grab these parameters from the URL of the browser and save them to a cookie.
The second javascript will retrieve these values from the cookie and then append all the tracking links on that page with the affiliate_id, source and aff_sub parameters as required.
So I have the codes, I just don’t know where and how to add them to my site. Any help gratefully received!
These are the instructions I received on the code that needs adding:
Sample Code
The following code requires js-cookie available from https://github.com/js-cookie/js-cookie Script to get parameters from the URL and save them to a cookie
Script to get parameters from cookies and add them to all tracking links
It looks like since this post was put up, that Wix have made it so much easier to add javascript to websites. Whether that be custom (as appears to be the case in this thread, or more standard (e.g. adding Google Analytics), Wix have come up with the goods to make it possible. Have never posted here before (so unsure on the rules) but we’ve done a 11 step guide on how to add javascript, which will hopefully be useful to people - How to add javascript to Wix websites - A1WebStats
My site is upgraded, however, when I try to insert my Javascript snippet via the custom tracking tools, nothing happens. Granted, it’s not a tracking tool, we’re trying to embed a webcam feed. I’ve set up a hidden page to test this, and when I check the page, it’s absolutely blank. I’ve tried it in all three available locations: head, body start, and body ed. Any advice from anyone? This is one of three webcam feeds we’re trying to insert.
<script>
TIMEOUT = 750;
errorcounter = 0;
var refreshInterval;
$(document).ready(function() {
// Active camera will refresh every 2 seconds
refreshInterval = setInterval(function() {
var random = Math.floor(Math.random() * Math.pow(2, 31));
$(‘img#camera’).attr(‘src’, ‘http://107.170.210.163:3000/camera?i=’ + Math.random());
}, TIMEOUT);
});
function imgError(image) {
image.src = “http://www.fourpawsdaycare.com/wp-content/uploads/2015/12/404camera.gif”;
Hi, I know this is an old thread but I wonder if someone can help me. I’m trying to inject javascript with the 11 step method described. I need to add the javascript only to the blog pages. The problem is that the individual blogs are not listed as actual pages because Wix pulls the content of the blogs from a database and generates the blog on the fly. Looking at the browser address box I can see that the actual URL of any particular blog is https://www.mywebsitename.com/post/post-title but like I said earlier, these pages are not listed in the pulldown where you can select specific pages (step 9).
Any ideas on how can I implement that ? Thank you !
I’m having the same thing happen, I add the code and nothing happens in preview. It’s a simple crypto coin price chart.
<script type="text/javascript">
baseUrl = "https://widgets.cryptocompare.com/";
var scripts = document.getElementsByTagName("script");
var embedder = scripts[ scripts.length - 1 ];
var cccTheme = {"General":{"borderColor":"#0b4d82"},"Header":{"background":"#0b4d82","color":"#fff200","displayFollowers":false},"Chart":{"fillColor":"#68d4ff","borderColor":"#2a0ebf"}};
(function (){
var appName = encodeURIComponent(window.location.hostname);
if(appName==""){appName="local";}
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
var theUrl = baseUrl+'serve/v1/coin/chart?fsym=BTC&tsym=USD';
As of this writing, you have to have a premium site to add code through the Wix site editor. Here is my work-around to add Facebook page like button - can be used for other code as well. I used Facebook Code generator ( https://developers.facebook.com/docs/plugins/like-button/# ) then created a page on my site that is hidden from the menu and hidden from SEO, pasted the first code into HTML iframe on this hidden page, then pasted the second code (iframe code, for the button itself) on the page where I wanted the button. Make sure the HTML box (iframe) is large enough so the sliders are not visible so there are no sliders on your visible site.
@yisrael-wix Thank you! I enabled Dev Mode (easy), but still does not give me access to Tracking Tools and Analytics so I can add code. Any suggestions appreciated. Wix should make their help articles so that non-programmers can follow them.
@kevinandmarsha Aha - now I know what you were referring to. You are correct that Tracking and Analytics requires a premium account in order to connect a domain.
Also, note that this post is originally from 2018 and you are much better adding a new post rather than bumping up an old post and referring back to this old post in a link, otherwise the post could be closed.