A JavaScript code โsnippet designed to enhance user engagement and ad integration on the laverita โคwebsite was recently updated, revealing details aboutโ its functionality in tracking internal โlinks, sponsoring sidebar posts, and implementing video playbackโ with integrated advertising.The code, executed within โคthe website’sโข framework, utilizes librariesโ like RebelMouse and Video.js to deliver โthese features.
The โฃupdates, implemented โon โor before November 2, 2023, focus on three primary areas:โฃ link tracking, sponsored โcontentโ display, and video player functionality. Specifically,the code adds UTMโฃ parameters to internal links originating from the sidebar – ‘?utm_source=sidebar’ – toโ monitor traffic sources. It also applies specific classes (‘posts-sidebar-sponsored’) toโ sponsored postsโ within the sidebar, distinguishing them from โขorganic content.A core component involves a video playback function (videofunc) that dynamically embeds Video.js players, supports both S3-hosted MP4 videos and YouTube content, and integrates with Google’s Interactive Media Ads (IMA) for preroll โadvertising.
The video player implementation is triggered by clicksโฃ onโ elements with โฃthe class ‘post-video’.Upon activation, โคthe function fetchesโ video โฃURLs, determines the appropriate โtechnology order (HTML5 for S3, YouTube otherwise), and constructs a video player with specific configurations, including autoplay and โคad integration. The ad requests are directed to ‘https://pubads.g.doubleclick.net/gampad/ads?iu=/150134580/laverita-Preroll’, โขincorporating data like page URL, referrer, and a unique correlator value for tracking purposes. Additionally, the โcode inserts ad units โคwithin article previews, utilizing a div with the ID ‘inarticle’ and class ‘gmp’.These updates aim to improve content โtracking,monetize sidebar content,and enhance the video viewing experience with targetedโฃ advertising.