ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Setting up Chartbeat, EE stripping out site ID code?

February 17, 2011 1:04pm

Subscribe [5]
  • #1 / Feb 17, 2011 1:04pm

    metsgrrl

    22 posts

    I’m trying to implement Chartbeat on my EE site, metsgrrl.com. I am cutting and pasting the embed code into two templates on the site, but somehow when viewing source, EE is stripping out the variable that contains the site ID.

    When I cut and paste the code from the EE control panel, this is the code:

    [removed]
    var _sf_async_config={uid:20167,domain:"metsgrrl.com"};
    (function(){
      function loadChartbeat() {
        window._sf_endpt=(new Date()).getTime();
        var e = document.createElement('script');
        e.setAttribute('language', 'javascript');
        e.setAttribute('type', 'text/javascript');
        e.setAttribute('src',
           (("https:" == document.location.protocol) ? "https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/" : "http://static.chartbeat.com/") +
           "js/chartbeat.js");
        document.body.appendChild(e);
      }
      var oldonload = window.onload;
      window.onload = (typeof window.onload != 'function') ?
         loadChartbeat : function() { oldonload(); loadChartbeat(); };
    })();
    
    [removed]

    But if you do a view Source on the web site, this is what you see:

    [removed]
    var _sf_async_config=;
    (function(){
      function loadChartbeat() {
        window._sf_endpt=(new Date()).getTime();
        var e = document.createElement('script');
        e.setAttribute('language', 'javascript');
        e.setAttribute('type', 'text/javascript');
        e.setAttribute('src',
           (("https:" == document.location.protocol) ? "https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/" : "http://static.chartbeat.com/") +
           "js/chartbeat.js");
        document.body.appendChild(e);
      }
      var oldonload = window.onload;
      window.onload = (typeof window.onload != 'function') ?
         loadChartbeat : function() { oldonload(); loadChartbeat(); };
    })();
    
    [removed]

    The key line is var _sf_async_config=;

    Why is this happening? I did a search on Chartbeat and did not see any previous discussions regarding implementing this code. My apologies if this is something obvious but I’ve never had this happen before, I have multiple different trackers on the site and have never had EE just plain take it out.

    Thank you in advance for help.

  • #2 / Feb 17, 2011 5:40pm

    Ingmar

    29245 posts

    When I cut and paste the code from the EE control panel, this is the code:

    var _sf_async_config={uid:20167,domain:"metsgrrl.com"};

    Make sure EE doesn’t consider your code an EE variable. This is most easily done by introducing additional linbreaks, like so:

    var _sf_async_config={
    uid:20167,domain:"metsgrrl.com"
    };
  • #3 / Feb 17, 2011 5:57pm

    metsgrrl

    22 posts

    Thanks so much for your response. I did that, but it’s still stripping it out.

    It’s not like I don’t have other javascript on the site.

    Any other ideas?

  • #4 / Feb 18, 2011 4:11am

    John Henry Donovan

    12339 posts

    metsgrrl,

    What version and build of EE are you using?

    Can you try the embed code just in a regular blank template on its own with nothing else in it?

  • #5 / Feb 18, 2011 11:13am

    metsgrrl

    22 posts

    I am using 1.6.7.

    I tried putting it into a template on its own and embedding it into the site. (I"ve used that for other situations in which code just wasn’t rendering.) Nope.

    I tried putting it in a div set up to display ads, both in the template and out of the template (which I imagine is there to allow for the display of script). Nope.

    Is there some kind of class I can set up or other container I can put this in? It seems astonishing to me that Chartbeat of all things won’t work.

    Thanks again.

    Caryn

  • #6 / Feb 18, 2011 3:45pm

    Ingmar

    29245 posts

    I tried putting it into a template on its own and embedding it into the site. (I"ve used that for other situations in which code just wasn’t rendering.) Nope.

    Did you set the template type to “Javascript” as well? You could also use a fully static file on your server.

  • #7 / Feb 18, 2011 3:58pm

    metsgrrl

    22 posts

    Yep, set the template to Javascript.

    I’m just going to have to face the fact that I can’t use Chartbeat with my EE configuration. I’m not smart enough to figure it out, I thought I’d learn EE by now, but just don’t have the time to dig in to be that competent.

    Thanks.

  • #8 / Feb 19, 2011 4:47pm

    Greg Salt

    3988 posts

    Hi metsgrrl,

    I don’t have a version 1.6.7 site to test this on but it seems to work just fine on my local version 1.7.0 site and I am not seeing any code stripping. Are you in a position to upgrade to 1.7.0?

    Cheers

    Greg

  • #9 / Mar 08, 2011 9:12am

    modgrrl

    3 posts

    We have version 1.7.0 of EE running and also can’t get Chartbeat to run on our installation for the same reason the other user is having. We also can’t use Meebo.

    We’ve had to have JS developed specifically for EE for other things to make them work and that is a real pain.

    Why don’t standard JS files from major providers like Chartbeat work seamlessly on EE when they work fine on other CMS systems like WordPress?

    What can we do to get this working?

  • #10 / Mar 08, 2011 1:18pm

    Barry Cogan

    291 posts

    Hi Metsgrrl,

    I am sorry that this is causing so much frustration.

    When it was suggested to introduce linebreaks into that code did you do:

    var _sf_async_config={
    uid:20167,domain:"metsgrrl.com"
    };

    or

    var _sf_async_config = {
         uid: 20167, 
         domain: "metsgrrl.com"
    };

    If you did not try it the second example please do so (make sure to keep all the spacing). 
    In addition can you also set your Debug Preference to “1:PHP/SQL error messages shown only to Super Admins”.
    You can find this setting by going to: Admin > System Preferences > Output and Debugging Preferences (fifth setting down)
    This should highlight any other errors that could be causing this issue.

    It also wouldn’t hurt to clear your caches: Admin > Utilities > Clear Cached Data (Select All caches and submit)

    Let us know how that works out for you!

    Best regards,
    Barry

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases