We make tools that make websites.

Forums (Archived)

The Solspace Support Forums are now CLOSED (read-only)

Check out our new support options here. Please refer to this blog post for more information.

   

Morsels Messing with Javascript Code?

RankRankRank

Total Posts: 122

Joined: Sep 24, 2007

PM

Ignore

 

Hello,

Is there any reason why switching from a global variable to a template morsel would mess up javascript tracking code?  I ask because after I switched I noticed a huge drop in our sites quantcast analytics.

Here is the code

<!-- Quantcast Tag --> 
[removed] 
var _qevents _qevents || [];
 
(function() 
{
var elem document.createElement('script');
elem.src = (document.location.protocol == "https:" "https://secure" "http://edge") + ".quantserve.com/quant.js";
elem.async true;
elem.type "text/javascript";
var 
scpt document.getElementsByTagName('script')[0];
scpt[removed].insertBefore(elemscpt);
})();
 
_qevents.push([,
{
qacct
:"p-a0gOdUACucKCE" // Complex Media Network
}]);
[removed] 
 
<noscript
<
div style="display:none;">
<
img src="//pixel.quantserve.com/pixel?a.1=p-c2kcDWkxt5nCs&a.2=p-a0gOdUACucKCE" border="0" height="1" width="1" alt="Quantcast" />
</
div>
</
noscript
<!-- 
End Quantcast tag --> 

I looked at the output and it seems to be the same, however this was the only change I made around that time that I can recall.

RankRankRank

Total Posts: 122

Joined: Sep 24, 2007

PM

Ignore

 

I just looked closer at the code and it appears to be filtering out the following piece in bold:


_qevents.push([{
qacct:“p-c2kcDWkxt5nCs”

},
{
qacct:“p-a0gOdUACucKCE” // Complex Media Network
}]);


I’ve heard this has to do with the brackets, but I cant figure out why it would pull that piece out but not pull out the piece below it.  They both seem similar.

Avatar
RankRankRankRank

Total Posts: 1305

Joined: Mar 30, 2004

PM

Ignore

 

Dave,

Morsels runs all code through the standard EE template parser. There is some intermediary code in the middle built by Solspace and we’ll review just to be sure. But I think this is an EE thing. We can continue to troubleshoot, but wanted to let you know my first impression.

mk

Signature

Avatar
RankRankRankRank

Total Posts: 1305

Joined: Mar 30, 2004

PM

Ignore

 

Dave,

You mentioned that you had converted some code from Global Variables over to Template Morsels and I wanted to record here for whoever might read this thread that Global Variables will likely perform better than morsels, although they don’t get parsed.

mk

Signature

RankRankRank

Total Posts: 122

Joined: Sep 24, 2007

PM

Ignore

 

Good to know.  What I was trying to do was combine my sidebar and footer into one morsel.  I figured that would cut down on server load since its one element instead of two.

Avatar
RankRankRankRankRank

Total Posts: 9901

Joined: Jan 8, 2009

PM

Ignore

 

Hi dmacli,

Just to give a stab at it, could you try putting curly braces alone on their own line, with line breaks before and after the curly brace? Somehow EE appears to be parsing some brackets, although I agree with you that where it’s interpreting and removing code is odd smile

Signature

RankRankRank

Total Posts: 122

Joined: Sep 24, 2007

PM

Ignore

 

Hey Nicolas,

That didnt work.  However I fixed the issue.  It was caused by EE like you had suspected.

Turns out if you have debug preferences set to 0 EE will strip out some stuff in brackets.  Setting Debug Preferences to 1 eliminates that issue.

You can see the full thread here: 

http://expressionengine.com/forums/viewthread/195012/

Avatar
RankRankRankRankRank

Total Posts: 9901

Joined: Jan 8, 2009

PM

Ignore

 

Great! smile
I think I now remember a similar issue for another addon with debug preferences affecting EE parsing between brackets. Thank you for refreshing my memory grin

Signature