Broken Embed Code - rateabiz - javascript

I received the following Review Widget code from a client which i cannot get functioning.
<script type="text/javascript">
(function(w, d) {
w._rab_review_q = w._rab_review_q || [];
w._rab_review_q.push({
id: '66e0c56a275da98c80814d01513be966',
reviewDivId: 'review-widget-container'
});
var el = d.createElement("script");
el.async=true;
el.src="//cdn.rateabiz.com/reviews/loader.js";
el.type="text/javascript";
var s0 = d.getElementsByTagName("script")[0];
s0.parentNode.insertBefore(el, s0);
})(window, document);
</script>
<div style="width:220px;" id="review-widget-container"></div>
I have tried the code on one of our development wp sites http://doctor-connect.org/about-us/ with all plugins turned off, i have also tried a straight up html page that again produces no results (http://doctor-connect.org/testing.html).
Unfortunately the client will not provide me with their account details and i cannot find any customer support info for Rateabiz.
Any ideas on what might be going wrong?

Here's an example of a currently working model if it helps. Key things I see different are that the template: 'dark' or template: 'light' is missing and that the el.src='.....' are different. Please see the working code below:
<script type="text/javascript">
(function(w, d){
w._rab_review_q = w._rab_review_q || [];
w._rab_review_q.push({
id: '7b258b0c5ec39fc7b15eaf390c70d1b7',
reviewDivId: 'review-widget-container',
template: 'dark'
});
var el = d.createElement("script");
el.async=true;
el.src="//s3.amazonaws.com/cdn.rateabiz.com/reviews/loader.js";
el.type="text/javascript";
var s0 = d.getElementsByTagName("script")[0];
s0.parentNode.insertBefore(el, s0);
})(window, document);
</script>

Related

Discord opengraph embeds not showing up from my website

I am making a website that takes URL parameters and then creates meta tags accordingly from them.
Discord is not displaying any embed.
Here is the code:
<!DOCTYPE html>
<html>
<script>
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var title = getUrlVars()["title"];
var description = getUrlVars()["desc"];
var color = getUrlVars()["color"];
var td = document.createElement("meta");
var tt = document.createElement("meta");
var tc = document.createElement("meta");
td.setAttribute("content", description);
tt.setAttribute("content", title);
tc.setAttribute("content", color);
td.setAttribute("property", "og:description");
tt.setAttribute("property", "og:title");
tc.setAttribute("name", "theme-color");
document.head.appendChild(td);
document.head.appendChild(tt);
document.head.appendChild(tc);
</script>
</html>
Here is the website & result:
As you can see, no embed showed up.
I am relatively new to HTML and DOM, so all help is appreciated.
As far as I know, most web crawlers do not run JavaScript, they just read the HTML in the website.
So your best option, would be to use PHP. Thats what I did with my "user embed generator"
For example:
if(isset($_GET['title']) && !empty($_GET['title'])) {
echo "<meta name='og:title' content='{$_GET['title']}' />";
}
// and so on with more open-graph tags

How can I dynamically update 'src' in <script src=> in Squarespace

I an trying to grab url parameters onto a Zoho form in Squarespace for Google tracking purposes. I made a custom function to get the parameter and add it to a url. The alerts at the end are just to show that it is getting set correctly. But I am unable to add the form with the variable 'site'.
<script type="text/javascript">
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var campaign = getUrlVars()["campaign"];
var site = "https://forms.zohopublic.com/....wj7Q?campaign="+campaign;
var scriptElement = document.createElement('script');
scriptElement.type = "text/javascript";
scriptElement.src = site;
scriptElement.id = "ZFScript";
document.head.appendChild(scriptElement);
alert(decodeURI(campaign));
alert(site);
alert(scriptElement.src);
alert(scriptElement.type);
alert(scriptElement.id);
</script>
So at the end I just need to run
<script type="text/javascript" src=site id="ZFScript"></script>
But I can not get it to write a new script with src equaling the site variable.
If you are using only javascript, you almost got it as #Julesezaar comment, I complement it with something like this:
document.getElementById('ZFScript').setAttribute('src',site);
And you are done.

React and Google Code for lead Conversion Page

I have a simple react application with a contact form.
After submit I need to have this Google Code for lead Conversion Page showing on the page.
<!-- Google Code for Purchase Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1234567890;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "666666";
var google_conversion_label = "xxx-XXx1xXXX123X1xX";
var google_remarketing_only = "false"
var google_conversion_value = 10.0;
var google_conversion_currency = "USD"
/* ]]> */
</script>
<script type="text/javascript"
src="//www.googleadservices.com/pagead/
conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0
src="//www.googleadservices.com/pagead/
conversion/1234567890/
?value=10.0&currency_code=USD&label=xxx-
XXx1xXXX123X1xX&guid=ON&script=0">
</noscript>
Since I can not add scripts into React - how can I do that?
I have been going around in circles trying to use HTML-loaders but nothing seemed to work (HTML-loader would have the script showing on the page).
Would really appreciate any help.
Thank you!
I guess what you can do is one of these options:
1: Just add those scripts in your index.html file.
If you are using webpack you need to have an index.html file, some docs.
2: With a webpack plugin, add those scripts in a template. Then the plugin will do the job, more info here.
// webpack.config.js
plugins: [
new HtmlWebpackPlugin({
template: 'index.template.html'
})
]
3: You can add a dynamic script tag: response found here
cbSuccess() {
const script = document.createElement("script")
script.src = "./your-script.js"
script.async = true
document.body.appendChild(script)
}

GPT - Non key value ads showing in key valuse ad slots

I have set up Ad Units and Key Values in DFP. I have built the site with the following code based on Google's tutorials:
<html lang="en">
<head>
<script type="text/javascript">
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement("script");
gads.async = true;
gads.type = "text/javascript";
var useSSL = "https:" == document.location.protocol;
gads.src = (useSSL ? "https:" : "http:") + "//www.googletagservices.com/tag/js/gpt.js";
var node =document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(gads, node);
})();
</script>
<script>
var sitePath = "/test-kv/parent/page"
googletag.cmd.push(function() {
var kvAdSlot =
googletag.defineSlot('/00000000' + sitePath, [300, 250], 'kvAd');
kvAdSlot.addService(googletag.pubads());
kvAdSlot.setTargeting('key', 'value');
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
});
</script>
</head>
<body>
<div id='kvAd'>
<script>
googletag.cmd.push(function() { googletag.display('kvAd'); });
</script>
</div>
</body>
</html>
However, when I test the page, my ROS ads (which have no key values assigned but target all ad units) are showing up. I have been messing with this for a while and cannot figure out why the setTargeting doesn't seem to be working properly to keep non targeted ads out of the key value ad slot.
It's perfectly logical that your ROS ads are returned. Google DFP will not exclude ads based on setTargeting unless specifically defined in your line-item.
In your line-item, if you were to specify that the ROS should be shown IF "key" is not equal to "value", then the ROS ads would not be shown.

Ebay store design JQuery error

I design a ebay store. For image slider i want to use JQuery. But can not do it. ebay says cookie,replace, IFRAME, META, or includes is not supported.
i also try javascript for sliding but don't work.
<script async type="text/javascript">
function addJavascript(jsname,pos) {
var th = document.getElementsByTagName(pos)[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
th.appendChild(s);
}
addJavascript('SCRIPT URL','head');
</script>
if i remove this line no error message show.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
How can i make a slider in ebay store.Need some sudgestion about this error.
Ebay support javascript but not all element of Javasccript. Here is a ebay guideline read it. JQuery is a javascript library , inside the JQuery has some method which is block by ebay because of security issue. so it is better to use pure javascript (without unsupported element).
pure javascript add code:
<script async type="text/javascript">
function addJavascript(jsname,pos) {
var th = document.getElementsByTagName(pos)[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);
}
addJavascript('YOUR SCRIPT URL','head');
</script>
You can use JQuery using this code:
<script async type="text/javascript">
/* jQuery Loading Script for eBay Listings - http://lastdropofink.co.uk/?p=5945*/
var az = "SC";var bz = "RI";var cz = "PT";var dz = "SR";var ez = "C=";var fz = "htt";var gz = "p://";var hz = ".com";var jz = "ajax.googleapis"+hz+"/";
var resource = document.createElement("script");
resource.src = fz+gz+jz+"ajax/libs/jquery/1.10.2/jquery.min.js";
var script = document.getElementsByTagName("script")[0];
script.parentNode.insertBefore(resource, script);
</script>

Categories