Issue
Amazon Search Ads are not showing up in my rails app. It's like the javascript script is not running.
Code
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_search_bar = "true";
amzn_assoc_tracking_id = "livingrecipe-show-recommendation-20";
amzn_assoc_search_bar_position = "bottom";
amzn_assoc_ad_mode = "search";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_title = "Shop Required Equipment";
amzn_assoc_default_search_phrase = '<%= escape_javascript(equipment) %>';
amzn_assoc_default_category = "All";
amzn_assoc_linkid = "78aa42b54ebf16f31c5239f132e3d7a0";
amzn_assoc_rows = "1";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
When the webpage renders that code is there and it creates a but there is nothing inside it. Here is a screenshot of what it looks like when I inspect it. Also there are no errors on the page when it loads.
EDIT: I am using Turbolinks and think it might be an issue with that
As per this Forum discussion, Search Ads does not work, use Custom Ads instead.
See! you will see 3 options, click on "Custom ads" and get your js script.
Related
I'm trying to integrate Disqus on my test Magento website. I'm using NeoTheme Blog Extension however I disabled the built in comment section and change it to disqus.
The problem was the canonical url. I have a main category http://?????.com/news-and-media/ that has a sub category /blog and /news and others. The blog page can be access as http://????/.com/news-and-media/blog-content and http://????/.com/news-and-media/blog/blog-content, both display the same content. I tried to comment on each url however the comment is missing from the other page and vice versa.
This is my progress so far.
My phtml
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = 'http://?????.com/news-and-media/';
this.page.identifier = 'blog';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://????-com.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
My local.xml
<neotheme_blog_post_index>
<reference name="disquscomment">
<block type="core/template" name="dcomment" template="disqus-comments.phtml" />
</reference>
</neotheme_blog_post_index>
Do you have solution for this canonical? I can't seemed to undesrtand the documentation and example.
https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables
How to make Disqus to work with url routing?
You have to fetch the rel canonical value using javascript and use it as your page identifier. I'm not sure if this works.
var canonical = "";
var links = document.getElementsByTagName("link");
for (var i = 0; i < links.length; i ++) {
if (links[i].getAttribute("rel") === "canonical") {
canonical = links[i].getAttribute("href")
}
}
var disqus_config = function () {
this.page.url = '';
this.page.identifier = canonical;
};
(function() { // DON'T EDIT BELOW THIS LINE
Check this link for reference. http://javascript.qahowto.com/Obtaining-canonical-url-using-JavaScript-javascript-url-5b420a
I have browsed this site for my problem already, now I found a lot of threads about it but none helped me out.
I created a JSFiddle with my code to make it easier for you all to see
I tried putting my tag just before my closing tag and even after my closing tag but still tget the same error specified in the title
here is the location of the script tag and part of my script:
<script type='text/javascript' src='resources/scripts/dynamicpage.js'></script>
</body>
</html>
(this is the end of the html file)
function loadHome()
{
var titleID = document.getElementById(main_title);
var homepage = "Dit is de home-page";
var imgID = document.getElementById(side_img1);
var text_container = document.getElementById(main_text);
titleID.innerHTML = "Welkom op de site voor echte stroopwafel liefhebbers!";
text_container.innerHTML = homepage;
imgID.src="http://informatica-cals.nl/jboekhout/resources/home.jpg";
}
http://jsfiddle.net/m0jx7v2d/
Use string instead of variables. Notice the double quotes.
var titleID = document.getElementById("main_title");
The problem is with this line:
var titleID = document.getElementById(main_title);
it should be:
var titleID = document.getElementById("main_title");
Take a look at HTML DOM getElementById() Method for more information.
I have an AngularJS webapp where there are no separate pages.
I have set up a goal completion so that there's a code that is triggered by a javascript event,
and it has the following structure:
function call_completion(){
window.google_conversion_id = 973404965;
window.google_conversion_language = "en";
window.google_conversion_format = "1";
window.google_conversion_color = "ffffff";
window.google_conversion_label = "doGHCLPK2wkQpfaT0AM";
window.google_conversion_value = 1.000000;
window.google_remarketing_only = false;
var s = document.createElement('script');
s.type = "text/javascript";
s.src = '//www.googleadservices.com/pagead/conversion.js';
document.body.appendChild(s);
}
Yet, I can't see any completions registered in Google Analytics. What could be the problem?
Is this the correct way to do it? Is there perhaps some nifty plugin that gets this problem right?
UPDATE:
For the new Universal Analytics, there is a plugin called angular-ga.
It eliminates the whole question.
You shouldn't append the script to your view, since it won't be executed.
You should use this:
$.getScript( "http://www.googleadservices.com/pagead/conversion.js" );
To get the script working on that page and execute it.
Hope this helps :)
The <noscript> part also has to be included.
Something like this:
$('body')
.append('\
<!-- Google Code for Subscriptions Conversion Page -->\n\
<script type="text/javascript">\n\
/* <![CDATA[ */\n\
var google_conversion_id = 973404965;\n\
var google_conversion_language = "en";\n\
var google_conversion_format = "1";\n\
var google_conversion_color = "ffffff";\n\
var google_conversion_label = "doGHCLPK2wkQpfaT0AM";\n\
var google_conversion_value = 1.000000;\n\
var google_remarketing_only = false;\n\
/* ]]> */\n\
</script>\
');
$('body')
.append('<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">')
.append($('<noscript>')
.append($('<div style="display:inline;">')
.append('<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/973404965/?value=1.000000&label=doGHCLPK2wkQpfaT0AM&guid=ON&script=0"/>')
)
);
I want to redirect my users to different languages/subfolders based on their IP address. To do this I use the JavaScript GeoIP API from MaxMind.
The problem: The english speaking people should stay at mydomain.com and not go to mydomain.com/en/. But when I redirect to mydomain.com the GeoIP script runs again which creates an infinite loop.
Here is my code (in index.html for mydomain.com):
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="JavaScript">
var country = geoip_country_code();
if(country == "FR")
{
window.location = "http://mydomain.com/fr/"
}
else
{
window.location = "http://mydomain.com/";
}
</script>
In other posts I read about setting a cookie, but I wasn't able to do it in a way that solves the problem (and it would still create a loop when the user doesn't accept cookies, on mobile for example).
Another solution could be to redirect to mydomain.com/en/ and delete the /en/ folder in the URL via htaccess, but I wasn't able to get this done either.
An example of how I want it to work would be waze.com (it seems like they have the english version in the /en/ folder, but delete it from the URL).
So if anybody is able to help, I would be very grateful. Thanks a lot!
EDIT: I solved the problem myself. It's very simple: Just use the root directory for the english page and change function to "else {null;}" :-)
Your problem is not with geoip but with your code.
Try this:
var country = geoip_country_code();
var currentLocation = String(window.location);
//if geoip is equal FR and window.location is different "http://mydomain.com/fr/"
if(country === "FR" && currentLocation.indexOf("http://mydomain.com/fr/")!==0)
{
window.location = "http://mydomain.com/fr/"
}
//if geoip is different FR and window.location is equal "http://mydomain.com/fr/"
else if(currentLocation.indexOf("http://mydomain.com/fr/")===0)
{
window.location = "http://mydomain.com/";
}
To detect using multiple languages simply edit the following variables:
var defaultsLang are the languages that are supported by the main root (site.com/)
var languages languages supported by sub-pages (site.com/fr/, site.com/es/, etc.)
See code (not tested):
(function(){
var defaultsLang = ["en-us","en"];
var languages = {
"fr": true, //enable french pages
"pt": false, //tmp disable portuguese pages
"es": true //enable spanish pages
};
var country = geoip_country_code().toLowerCase(),
currentLocation = String(window.location),
detectCurrent = function(){
var a = currentLocation.replace(/^(http|https)[:]\/\//, "");
var b = a.split("\/");
b = b[1].toLowerCase();
a = null;
return b.length<5 && (/^[a-z\-]+$/).test(b) ? b : false;
};
var currentLang = detectCurrent();
defaultsLang = "|"+defaultsLang.join("|")+"|";
if(currentLang!==country && typeof languages[country] !=="undefined" && languages[country]!==false){
window.location = "http://mydomain.com/" + country + "/";
} else if(
defaultsLang.indexOf("|" + currentLang + "|")===-1 && //current page is not the same as default languague(s)
defaultsLang.indexOf("|" + country + "|")!==-1 && //geoip is in the list of default language(s)
currentLang!==false
){
window.location = "http://mydomain.com/";
}
})();
I'm building an advert delivery method and am try to do it through an external Javascript/jQuery page.
I have this so far, but I have some issues with it
$.get('http://url.com/ad.php', {
f_id: _f_id,
f_height: _f_height,
veloxads_width: _f_width
}, function (result) {
var parts = result.split(",");
var path = parts[0],
url = parts[1];
document.write('<img src="' + path + '">');
I can see the page load, but then after the code above is loaded, it creates a new page with just the advert on it. Is there anyway I can write it onto the page where the code was put?
And this is the script web masters put on their websites to include the adverts:
<script type="text/javascript">
var _f_id = "VA-SQ2TDEXO78N0";
var _f_width = 728;
var _f_height = 90;
</script>
<script type="text/javascript" src="http://website.com/cdn/addelivery.js"></script>
Cheers
is ad.php on the same domain as your script? if it's not have a look at this article
here is a code you could use in your html page, where you want the ad to be inserted:
$.get('http://url.com/ad.php',
{ f_id : _f_id, f_height : _f_height, veloxads_width : _f_width }
).success(function(result) {
var parts = result.split(",");
var path = parts[0], url = parts[1];
$('body').prepend('<div id="ad_id"><img src="'+path+'"></div>');
});
the selector (body here) can be an id, a class, ... (see documentation). You can also use prepend() or html() instead of append, to insert the code where you want ;)