I am trying to remove special characters from Google Analytics tags. I have the following script and I can't figure out why it's not working. It's a mix of JSP and JavaScript, which I know very little about! On the job learning...
                <script type="text/javascript">
                function removeSplChars(inStr) {
                inStr = inStr.replace(/[^a-zA-Z0-9 ]/g, "");
                return inStr;
                }
                var _gaq = _gaq || [];
                _gaq.push(['_setAccount', '<c:out value="${profileId}"/>']);
                <c:choose>
                <c:when test="${(lastCmdName eq 'CategoryDisplay') or (lastCmdName eq 'ProductDisplay')}" >
                _gaq.push(['_setCustomVar',
                2, // This custom var is set to slot #2.
                '<c:choose><c:when test="${WCParam.source eq 'search'}">Search</c:when><c:otherwise><c:out value="${topCat}" /></c:otherwise></c:choose>', // The top-level name for your online content categories.
                '<c:choose><c:when test="${WCParam.source eq 'search'}">Search <c:out value="${WCParam.searchTerm}" /></c:when><c:otherwise><c:out value="${topCat}" />|<c:out value="${subCatA}" />|<c:out value="${subCatB}" />|<c:out value="${subCatC}" /></c:otherwise></c:choose>', // Records value of breadcrumb name
                3 // Sets the scope to page-level.
                ]); 
                </c:when>
                <c:otherwise>
                </c:otherwise>
                </c:choose>
                removeSplChars(<c:out value="${topCat}" />, <c:out value="${subCatA}" />, <c:out value="${subCatB}" />, <c:out value="${subCatC}" />);
                 _gaq.push(['_trackPageview']);
                (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                })();
                </script>
Am I missing some () or something somewhere? I get an "unexpected token ;" error message in the console. I tried placing the call for removeSplChars within a $(document).ready(function() {});
to no avail.
I have checked the following posts but the advice does not help me: Function is not Called javascript function not getting called
I have another post here: JavaScript Remove special characters string not working
Thank you.
Adding code as seen via View Source:
                <script type="text/javascript">
                function removeSplChars(inStr) {
                inStr = inStr.replace(/[^a-zA-Z0-9 ]/g, "");
                return inStr;
                }       
                var _gaq = _gaq || [];
                _gaq.push(['_setAccount', 'UA-33021136-1']);
                _gaq.push(['_setCustomVar',
                2, // This custom var is set to slot #2.
                'Dine & Entertain', // The top-level name for your online content categories.
                'Dine & Entertain|Bowls & Platters||', // Records value of breadcrumb name
                3 // Sets the scope to page-level.
                ]); 
                $(document).ready(function() {
                removeSplChars(Dine & Entertain, Bowls & Platters, , );
                });
                _gaq.push(['_trackPageview']);
                (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                })();
                </script>