Twitter Tracking Code breaking page functionality


#1

Hi I have received the follwoing tracking code from twitter but when i place it in the body of my site it completely screws up the functioanlity of other features on the page.

Ive tried to use online javascript validators to spot if there is an error but so far im having no luck. Could anyone assist please?

Cheers
Paul


#2

Are you placing JavaScript on your page generated by ads.twitter.com for tailored audiences or conversion tracking?


#3

Hi niall,

Thanks for response. I think i may of got to the bottom of the issue.

I was calling wigets.js on the same page for twitter embeds and because the tracking script was also on the same page it was conflicting (i think) I found this script here https://dev.twitter.com/web/javascript/loading which allows the twitter object to work asynchronously

<script>window.twttr = (function(d, s, id) {  var js, fjs = d.getElementsByTagName(s)[0],    t = window.twttr || {};  if (d.getElementById(id)) return t;  js = d.createElement(s);  js.id = id;  js.src = "https://platform.twitter.com/widgets.js";  fjs.parentNode.insertBefore(js, fjs);   t._e = [];  t.ready = function(f) {    t._e.push(f);  };   return t;}(document, "script", "twitter-wjs"));</script>

my previous script was as follows

@*<script>
    window.twttr = (function (d, s, id) {
        var t, js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src= "https://platform.twitter.com/widgets.js";
        fjs.parentNode.insertBefore(js, fjs);
        return window.twttr || (t = { _e: [], ready: function (f) { t._e.push(f) } });
    }(document, "script", "twitter-wjs"));</script>*@
<script>

Im not sure if my thinking is correct but it seems to have solved it

Cheers
Paul


#4