All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Output search keywords without having to duplicate code

Susan Swallow Ohtake 30 Nov 2013 03:56 question, complete

Hello,

I'm trying to send my keyword searches to Google analytics using low search. However, I have to do the following (repeat the script in two if statements). The issue seems to be that I have to send the keywords based on whether there is a result and also when there is not a result. Is there a better way to do this so that I don't have to repeat myself?

-----------------------------------------

{exp:low_search:results query="{segment_3}"}

{if count == 1}

{/if}

{if no_results}

{/if}

{/exp:low_search:results}

Replies

  1. Susan Swallow Ohtake 30 Nov 2013 04:00

    Looks like getsatisfaction stripped out the JavaScript that was in between my "if" statements. Anyway, doesn't really matter - it's the same exact script in both "if" blocks, hence the problem.

  2. Low 30 Nov 2013 08:58

    You could get the code out of the Results tag and use the Keywords tag instead.

  3. Susan Swallow Ohtake 30 Nov 2013 19:53

    Perfect, thank you!