When I inject this example GTM tag on a site the '==' in the src string is encoded as \x3d\x3d which fails to resolve. Is there a way to stop the encoding?
GTM tag:
<script type="text/javascript"> !function(o,t){var src="https://test#testsite.com/test/1MmE5ZDA4ZGExODZkOTQifQ==/assets/demo.js";
...
</script>
on page:
<script type="text/javascript"> !function(o,t){var src="https://test#testsite.com/test/1MmE5ZDA4ZGExODZkOTQifQ\x3d\x3d/assets/demo.js";
...
</script>
I had a similar issue trying to insert an src into an iframe. I was populating the query string with GTM variables that contained "=" but they would get encoded as %3D.
My solution was injecting the HTML tag on the page using Javascript instead.
OLD WAY (HTML)
<iframe height="1" width="1" frameborder="0" scrolling="no" src="https://www.something.com/?containerTagId={{containerID}}"></iframe>
NEW WAY (JAVASCRIPT)
<script>
var script = document.createElement('iframe');
script.height="1";
script.width="1";
script.frameborder="0";
script.scrolling="no";
script.name="conversion";
script.src = 'https://www.something.com/?containerTagId={{containerID}}';
document.body.appendChild(script);
</script>
Related
I added Adword Conversation Tracking to my webshop.
I have Magento shop and inside of body tag I have following code:
<!-- Google Code for Conversion_Adwords_DrSchaette Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 123456789;
var google_conversion_language = "de";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "RstGBPX52wEEk8Dz4wS";
var google_conversion_currency = "EUR";
var google_conversion_value = 1.00;
var google_remarketing_only = false;
var google_conversion_order_id = "100031728";
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//www.googleadservices.com/pagead/conversion/123456789/?value=1.00¤cy_code=EUR&label=RstGBPX52wEEk8Dz4wS&guid=ON&oid=100031728&script=0"/>
</div>
</noscript>
Google tag assistant report me following errors:
Code should be placed directly above the closing tag.
Conversion Value should be prefixed with standard currency.
Non-standard implementation
First error I know what it is, but second and third I don't know how to fix.
If the conversions are appearing properly in your AdWords account, then you can safely ignore these warnings. Google Tag Assistant can be a bit buggy sometimes.
I'm trying to insert a conversion tracking script into a thank you page that one is directed to upon completing a contact form. I'm working in Wordpress and using the WPWOX Custom Script Integration plugin to insert my script, which is as follows:
<!-- Google Code for contact-us/thank-you Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 978060811;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "OmTcCKWT6mQQi4yw0gM";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/978060811/?label=OmTcCKWT6mQQi4yw0gM&guid=ON&script=0"/>
</div>
</noscript>
However, when running Tag Assist I am given the error of "No HTTP response detected".
Any idea why I I'm getting the error? Here is the link to the thank you page http://expoprop.co.za/thank-you/
I was trying to include the Google Plus One button in a Meteor app for collaborative sketching and I noticed that the script tags inside templates are not executed.
<template name="gplus">
<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone" data-href="{{url}}"></div>
<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
console.log("Google Plus button");
(function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
</template>
I got the button to work by moving the script to a separate JavaScript file, but I still wonder why the inline-script didn't work.
I see the script tag on the console, but the script itself doesn't run. How does Meteor do this?
Meteor just inserts the contents of the gplus template into the DOM, so of course nothing happens because there is no script execution when elements are added to the DOM.
To fix this you can create a .js file and put it in the client folder, which Meteor will automatically include and execute for you (as well as minify in production).
Here is what I do to load the Google +1 Button in my application:
1. Add the JS library between the <head> tag of your application.
<head>
<!-- Load JS Library -->
<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
</head>
2. Insert the +1 Button.
<template name="myTemplate">
<div data-href="https://hackisition.com/" data-size="medium" class="g-plusone"></div>
</template>
3. Render the Button.
Template.myTemplate.rendered = function() {
return gapi.plusone.go();
};
I have 2 files in a very simple web application
The first is a standard index.html and it looks something like the below
<body>
<div id="add-stuff"></div>
<script id="the-template" type="text/x-handlebars-template" src="some-template.erb.html"></script>
<script type="text/javascript">
var data = [];
var source = $("#the-template").html();
var template = Handlebars.compile(source);
$('#add-stuff').html(template(data));
</script>
</body>
The second is my handlebars template "some-template.erb.html" and it looks something like the below
<table>
{{#each item}}
<tr><td>{{ item.name }}</td></tr>
{{/each}
</table>
The problem with the inline javascript I have above is that when I try the ".html()" part it always returns an empty string (as I'm linking in the erb.html file).
I've found a work around that lets me achieve this if I use $.ajax to pull in the template but I'd much prefer something like the above (so I can include the template client side w/out any nested jQuery callbacks).
Is this possible? If not what can I do do improve the $.ajax based approach?
** the ajax based approach that works is shown below **
<body>
<div id="add-stuff"></div>
<script type="text/javascript">
$.ajax({
url: 'some-template.erb.html',
cache: true,
success: function (source) {
var data = [];
var template = Handlebars.compile(source);
$('#add-stuff').html(template(data));
}
});
</script>
</body>
Here is a link to the stackoverflow question that showed the $.ajax version in a bit more detail
maybe its already outdated, but I found your question today and I have a suggestion for you or people who are dealing with the same problem. It's not a perfect one, but for small templates an option if you don't want to use ajax.
What do you think about writing the template as string in a variable in an external JS-file and inlcude it via script tag?
template.js
var source = '<table>\
{{#each item}}\
<tr><td>{{ item.name }}</td></tr>\
{{/each}';
index.html
<body>
<div id="add-stuff"></div>
<script src="template.js"></script>
<script type="text/javascript">
var data = [];
var template = Handlebars.compile(source);
$('#add-stuff').html(template(data));
</script>
</body>
I am using jQuery session in my master page. Anything I'm missing?
Code:
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.session("lnkID","A1")
});
</script>
Error:
Microsoft JScript runtime error: Object doesn't support this property or method
By your example alone, you're missing a reference to the required files, and you're not wrapping your jQuery code in script tags. You need to reference not only jquery-source, but jquery-json, and jquery-session as well.
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.json.js"></script>
<script type="text/javascript" src="scripts/jquery.session.js"></script>
Once you've got those in place, you need to place your logic within script tags:
<script type="text/javascript">
$(function(){
$.session("foo", "bar");
});
</script>
See the following demo for an example: http://www.jaysalvat.com/session/test1.html
Lastly, the language attribute of the script tag is deprecated. You can do away with it, but keep the type attribute.