Improved analytics in Elfsight (Actual Views, Interaction, Clicks, etc.)

Analytics on widget-level with number of views, interactions, click to Instagram etc.. View of weekly, monthly, yearly numbers

2 Likes

Hi there, @Vinduer_Inwido :waving_hand:

Thank you so much for the feedback!

Views stats is already available in your dashboard, but I agree that it would be awesome to have the info about clicks/interactions all in one place. We’ll try to consider this opportunity, especially of more users support this idea.

As for now, you can track clicks on the widget elements (posts, profile CTA button, Follow buttons) using the Google Analytics code. . Please add this part of the code to your website <head>:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ID');
</script>

In the code above, you need to replace G-ID with your actual website ID for Google Analytics. This article will help you find your ID - Find your Google tag ID.

And then just add the rest of the script to the Custom JS field on the Settings tab of your widget’s settings:

function eappsDispatchAnalyticsEvent(event, selector, config) {
	function sendEvent(config) {
		if (typeof ga !== 'undefined') {
			ga('send', 'event', {
				eventAction: config.action,
				eventCategory: config.category,
				eventLabel: config.label,
			});
		}
		if (typeof gtag !== 'undefined') {
			gtag('event', config.action, {
				event_category: config.category,
				event_label: config.label,
			});
		}
	}
	function isHitClass(e, selector) {
		return e.target && e.target.closest(selector);
	}
	if (isHitClass(event, selector)) {
		sendEvent(config);
	}
}

document.addEventListener(
	'click',
	function (event) {
		eappsDispatchAnalyticsEvent(
			event,
			'.eapps-instagram-feed-posts-item-overlay',
			{
				action: 'click',
				category: 'Post click',
				label: 'Elfsight Instagram Feed',
			}
		);
		eappsDispatchAnalyticsEvent(
			event,
			'.eapps-instagram-feed-posts-item-user-image',
			{
				action: 'click',
				category: 'Profile click',
				label: 'Elfsight Instagram Feed',
			}
		);
		eappsDispatchAnalyticsEvent(
			event,
			'.eapps-instagram-feed-popup-item-cta-button',
			{
				action: 'click',
				category: 'CTA button click',
				label: 'Elfsight Instagram Feed',
			}
		);
		eappsDispatchAnalyticsEvent(
			event,
			'.eapps-instagram-feed-popup-item-share',
			{
				action: 'click',
				category: 'Share button click',
				label: 'Elfsight Instagram Feed',
			}
		);
	},
	true
);

This article explains where you can find the info about clicks - Google Analytics 4 (GA4): Where to find my events - Elfsight Help Center.

Try it out and let us know if it helped :slightly_smiling_face:

2 Likes