Add active class to nav created from globals
Depends on your URL structure ultimately and whether you have sub pages, but I think the easiest way to do it would be something like:

{% if mainNav.navitems|length %}
 {% for row in mainNav.navitems %}
  &lt;li&gt;
    &lt;a href="{{ url(row.url) }}"
     {%- if craft.request.segment(1) == row.url %}class="active"{%- endif %}&gt;
     {{ row.name }}
    &lt;/a&gt;
  &lt;/li&gt;
 {% endfor %}
{% endif %}


You don't have to use the segment(1) method if it doesn't suit, take a look at the request docs to find something that suits your URLs