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.