Add Attributes to Identify Html Elements or Specify Event Name
Adding attributes to identify HTML elements for tracking
With the attributes for simple click event and customized click event, you should be able to track most of the HTML elements on your website. If you still cannot find a HTML attribute that can uniquely and persistently identify your HTML element (or the element group), such as in an A/B testing environment, you need to ask your website developer to add some attributes to the HTML element that can uniquely and persistently identify the HTML element.
You can add the following attributes that fits your website:
- Id or name: This is the simplest way and you can use SkyGlue simple customization to track events using these two attributes
- Other HTML element you may use for the element, e.g. “title” for any html tag,”alt” for image, “class” if they may share the same CSS style. See the full list of possible attributes here
- Using customized attributes that start with “data-“, e.g. data-promotion-group-id. This is a standard way for customized attributes in HTML5 . You can use the customized attributes even if you are not using HTML 5 on your web page. For example:
<li data-promotion-group-id=”shoes”>Latest men’s shoes</li>
<li data-promotion-group-id=”shoes”>Latest women’s shoes</li>
Adding attributes to customize event names for HTML elements for event tracking
If you use SkyGlue to track a group of HTML elements and you want to send different values to Google Analytics based on the specific links the user clicks, you can use SkyGlue macro to specify the event name. See details here.
If your HTML element does not have the attributes you want, you can add additional HTML attributes to describe the HTML element.
- Any HTML element you may use for the element, e.g. Id, name, “title” for any html tag,”alt” for image. See the full list of possible attributes here
- Using customized attributes that starts with “data-“, e.g. data-promotion-group-id. This is a standard way for customized attributes in HTML5. See HTML 5 spec. You can use the customized attributes even if you are not using HTML 5 on your web page. For example:
<li data-promotion-group-id=”shoes” data-promotion-link-type=”shoes_men”>Latest men’s shoes</li>
<li data-promotion-group-id=”shoes” data-promotion-link-type=” shoes_women”>Latest women’s shoes</li>
Now you can track the promotion link using the data-promotion-group-id, and specify the event name as ShoePromotion_{#data-promotion-link-type} in your SkyGlue portal. SkyGlue will send events with names like “ShoePromotion_shoes_men” See more about event name setting here