{% set previousAction = false %}
{% for action in actionDetails %}
    {% set customVariablesTooltip %}
        {% if action.customVariables is defined %}
            {{ 'CustomVariables_CustomVariables'|translate }}:
            {% for id,customVariable in action.customVariables %}
                {% set name = 'customVariablePageName' ~ id %}
                {% set value = 'customVariablePageValue' ~ id %}
                - {{ customVariable[name]|raw }} {% if customVariable[value]|length > 0 %} = {{ customVariable[value]|raw }}{% endif %}

                {# line break above is important #}
            {% endfor %}
        {% endif %}
    {% endset %}

    <li class="{% if action.goalName is defined %}goal{% else %}action{% endif %}"
        title="{{ action.serverTimePretty }}{% if action.url is defined and action.url|trim|length %}

{{ action.url }}{% endif %}{% if customVariablesTooltip|trim|length %}

{{ customVariablesTooltip|trim }}{% endif -%}
        {%- if action.generationTime is defined %}

{{ 'General_ColumnGenerationTime'|translate }}: {{ action.generationTime|raw }}{% endif %}
        {%- if action.timeSpentPretty is defined %}

{{ 'General_TimeOnPage'|translate }}: {{ action.timeSpentPretty|raw }}{% endif -%}">
        <div>
        {% if action.type == 'ecommerceOrder' or action.type == 'ecommerceAbandonedCart' %}
        {# Ecommerce Abandoned Cart / Ecommerce Order #}
            <img src="{{ action.icon }}"/>
            {% if action.type == 'ecommerceOrder' %}
                <strong>{{ 'Goals_EcommerceOrder'|translate }}</strong>
                <span style='color:#666;'>({{ action.orderId }})</span>
            {% else %}
                <strong>{{'Goals_AbandonedCart'|translate}}</strong>

                {# TODO: would be nice to have the icons Orders / Cart in the ecommerce log footer #}
            {% endif %}
            <p>
            <span {% if not isWidget %}style='margin-left:20px;'{% endif %}>
                {% if action.type == 'ecommerceOrder' %}
{# spacing is important for tooltip to look nice #}
{% set ecommerceOrderTooltip %}{{ 'General_ColumnRevenue'|translate }}: {{ action.revenue|money(clientSideParameters.idSite)|raw }}
{% if action.revenueSubTotal is not empty %} - {{ 'General_Subtotal'|translate }}: {{ action.revenueSubTotal|money(clientSideParameters.idSite)|raw }}{% endif %}

{% if action.revenueTax is not empty %} - {{ 'General_Tax'|translate }}: {{ action.revenueTax|money(clientSideParameters.idSite)|raw }}{% endif %}

{% if action.revenueShipping is not empty %} - {{ 'General_Shipping'|translate }}: {{ action.revenueShipping|money(clientSideParameters.idSite)|raw }}{% endif %}

{% if action.revenueDiscount is not empty %} - {{ 'General_Discount'|translate }}: {{ action.revenueDiscount|money(clientSideParameters.idSite)|raw }}{% endif %}
{% endset %}
                <abbr title="{{ ecommerceOrderTooltip }}">{{ 'General_ColumnRevenue'|translate }}:
                {% else %}
                    {% set revenueLeft %}{{ 'General_ColumnRevenue'|translate }}{% endset %}
                    {{ 'Goals_LeftInCart'|translate(revenueLeft) }}:
                {% endif %}
                    <strong>{{ action.revenue|money(clientSideParameters.idSite)|raw }}</strong>
                {% if action.type == 'ecommerceOrder' %}
                </abbr>
                {% endif %}, {{ 'General_Quantity'|translate }}: {{ action.items }}

                {# Ecommerce items in Cart/Order #}
                {% if action.itemDetails is not empty %}
                    <ul style='list-style:square;margin-left:{% if isWidget %}15{% else %}50{% endif %}px;'>
                        {% for product in action.itemDetails %}
                            <li>
                                {{ product.itemSKU }}{% if product.itemName is not empty %}: {{ product.itemName }}{% endif %}
                                {% if product.itemCategory is not empty %} ({{ product.itemCategory }}){% endif %}
                                ,
                                {{ 'General_Quantity'|translate }}: {{ product.quantity }},
                                {{ 'General_Price'|translate }}: {{ product.price|money(clientSideParameters.idSite)|raw }}
                            </li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </span>
            </p>
        {% elseif action.goalName is not defined%}
            {# Page view / Download / Outlink / Event #}
            {% if action.pageTitle|default(false) is not empty %}
                <span class="truncated-text-line">{{ action.pageTitle|rawSafeDecoded }}</span>
            {% endif %}
            {% if action.siteSearchKeyword is defined %}
                {% if action.type == 'search' %}
                    <img src='{{ action.icon }}' title='{{ 'Actions_SubmenuSitesearch'|translate }}' class="action-list-action-icon search">
                {% endif %}
                <span class="truncated-text-line">{{ action.siteSearchKeyword|rawSafeDecoded }}</span>
            {% endif %}
            {% if action.eventCategory|default(false) is not empty %}
                <img src='{{ action.icon }}' title='{{ 'Events_Event'|translate }}' class="action-list-action-icon event">
                <span class="truncated-text-line event">{{ action.eventCategory|rawSafeDecoded }} - {{ action.eventAction|rawSafeDecoded }} {% if action.eventName is defined %}- {{ action.eventName|rawSafeDecoded }}{% endif %} {% if action.eventValue is defined %}[{{ action.eventValue }}]{% endif %}</span>
            {% endif %}
            {% if action.url is not empty %}
                {% if action.type == 'action' and action.pageTitle|default(false) is not empty %}<p>{% endif %}
                {% if action.type == 'download' or action.type == 'outlink' %}
                    <img src='{{ action.icon }}' class="action-list-action-icon {{ action.type }}">
                {% endif %}

                {% if action.eventCategory|default(false) is not empty
                    and previousAction.url|default(false) == action.url %}
                    {# For events, do not show (url) if the Event URL is the same as the URL last displayed #}
                {% else %}
                    {% if action.url|trim|lower starts with 'javascript:' or
                          action.url|trim|lower starts with 'vbscript:' or
                          action.url|trim|lower starts with 'data:' %}
                        {{ action.url }}
                    {%  else %}
                    <a href="{{ action.url }}" rel="noreferrer" target="_blank" class="{% if action.eventCategory|default(false) is empty %}action-list-url{# don't put URL on new line for events #}{% endif %} truncated-text-line"
                       {% if overrideLinkStyle is not defined or overrideLinkStyle %}style="text-decoration:underline;"{% endif %}>
                       {{ action.url }}
                    </a>
                    {%  endif %}
                {% endif %}
                {% if action.type == 'action' and action.pageTitle|default(false) is not empty %}</p>{% endif %}
            {% elseif action.type != 'search' and action.type != 'event' %}
                <p>
                <span>{{ clientSideParameters.pageUrlNotDefined }}</span>
                </p>
            {% endif %}
        {% else %}
            {# Goal conversion #}
            <img src="{{ action.icon }}" />
            <strong>{{ action.goalName }}</strong>
            {% if action.revenue > 0 %}, {{ 'General_ColumnRevenue'|translate }}:
                <strong>{{ action.revenue|money(clientSideParameters.idSite)|raw }}</strong>
            {% endif %}
        {% endif %}
        </div>
    </li>

    {% set previousAction = action %}
{% endfor %}