Add Attributes to Identify Html Elements
Add attributes to identify HTML elements for tracking
With the attributes under Simple Click Event and Customized Click Event on the SkyGlue visual interface popup window, you should be able to track most of the HTML elements on your website. If you still cannot find an attribute that can uniquely and persistently identify a webpage 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 it.
You can add the following attributes that fit your website:
- Id or name: This is the simplest way to identify an element and you can track the event under the Simple Customization section in your SkyGlue portal.
- Some other HTML elements you may use are, 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.
- Use customized attributes that start with “data-“, e.g. data-promotion-group-id. This is a standard way to specify customized attributes in HTML5 . You can use the customized attributes even if you are not using HTML 5 on your web page. For example:
- data-promotion-group-id=”shoes”>Latest men’s shoes
- data-promotion-group-id=”shoes”>Latest women’s shoes
Add attributes to customize event names for HTML elements
If you use SkyGlue to track a group of elements and you want to send different values to Google Analytics based on the specific links a user clicks, you can use the SkyGlue macro to specify the event names. See details here.
If the element does not have the attributes you want, you can add additional HTML attributes to describe it.
- You may use any HTML element, e.g. Id, name, “title” for any html tag, “alt” for image. See the full list of possible attributes here.
- Using customized attribute that starts with “data-“, e.g. data-promotion-group-id. This is a standard way to specify 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:
- data-promotion-link-type=”shoes_men”>Latest men’s shoes
- data-promotion-link-type=”shoes_women”>Latest women’s shoes
Now you can track the promotion links 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 as “ShoePromotion_shoes_men”. See more on naming events here.