{"id":117,"date":"2025-01-16T17:32:27","date_gmt":"2025-01-16T15:32:27","guid":{"rendered":"https:\/\/lookanalyze.com\/blog\/?p=117"},"modified":"2025-01-16T17:32:27","modified_gmt":"2025-01-16T15:32:27","slug":"event-tracking","status":"publish","type":"post","link":"https:\/\/lookanalyze.com\/blog\/event-tracking\/","title":{"rendered":"Event Tracking With LookAnalyze"},"content":{"rendered":"<p>Event tracking allows you to track actions that visitors take on your site, such as button clicks, form submissions, newsletter sign-ups, and any other action that makes sense for your website.<\/p>\n<p>Setting up event tracking is very easy. All you have to do is follow these two steps:<\/p>\n<ol>\n<li>Create a custom event goal through the dashboard.<\/li>\n<li>Add a piece of JavaScript code to your website.<\/li>\n<\/ol>\n<h2>1. Create a Custom Event Goal<\/h2>\n<p>The first step is creating a goal, so LookAnalyze knows what to track. Follow these steps:<\/p>\n<ul>\n<li>Click Goals from the left menu.<\/li>\n<li>Click Create.<\/li>\n<li>From the dropdown menu, select &#8220;Custom Event&#8221;<\/li>\n<li>Enter a friendly name for your goal (this is what you&#8217;ll see in reports)<\/li>\n<li>You can optionally change the KEY to your desired value or leave it as it is.<\/li>\n<li>Copy the Javascript code (you&#8217;ll need it later) and click the CREATE button.<\/li>\n<\/ul>\n<p>Your screen should look like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-125 size-full\" src=\"https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal.webp\" alt=\"Create Custom Event Goal\" width=\"2256\" height=\"1398\" srcset=\"https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal.webp 2256w, https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal-300x186.webp 300w, https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal-1024x635.webp 1024w, https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal-768x476.webp 768w, https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal-1536x952.webp 1536w, https:\/\/lookanalyze.com\/blog\/wp-content\/uploads\/2025\/01\/create-custom-event-goal-2048x1269.webp 2048w\" sizes=\"auto, (max-width: 2256px) 100vw, 2256px\" \/><\/p>\n<h2>2. Add Javascript Code<\/h2>\n<p>The next step is to add the Javascript code you copied above to your website to inform LookAnalyze that an event has occurred.<\/p>\n<p>Here are some common use cases:<\/p>\n<h3>Track Link Clicks<\/h3>\n<p>There are two ways to track clicks to a specific link. The first is to add an onclick event to the ahref tag, like this:<\/p>\n<pre><code>&lt;a href=\"\/download\" onclick=\"lookanalyze_track.goal('download-pdf');\"&gt;Download PDF&lt;\/a&gt;<\/code><\/pre>\n<p>The second way is to use Javascript to target any\/all elements on a page with a specific ID or CLASS. In this method, ensure the javascript code for your events appears after any\/all IDs or CLASSES.<\/p>\n<p>Let\u2019s say you want to track an event when a customer clicks a link that looks like this:<\/p>\n<pre><code>&lt;a id=\"download-link\" href=\"\/download\"&gt;Download&lt;\/a&gt;<\/code><\/pre>\n<p>You\u2019d add the following script to your HTML (typically just above the element) to do this.<\/p>\n<pre><code>&lt;script&gt;\r\nwindow.addEventListener('load', (event) =&gt; {\r\n  document.getElementById('download-link').addEventListener('click', () =&gt; {\r\n    lookanalyze_track.goal('download-pdf');\r\n  });\r\n});\r\n&lt;\/script&gt;\r\n<\/code><\/pre>\n<h3>Track External Links<\/h3>\n<p>If you want to track clicks on links that point to an external domain, you could do something like this:<\/p>\n<pre><code>&lt;a href=\"https:\/\/amazon.com\/x\" onclick=\"lookanalyze_track.goal('amazon-link');\" class=\"ext-link\"&gt;Link to Amazon&lt;\/a&gt;\r\n<\/code><\/pre>\n<h3>Track Page Load Conversions<\/h3>\n<p>If you want to track page loads of specific pages and you don&#8217;t want to use the &#8220;PageView&#8221; goal, you can fire an event when a page loads:<\/p>\n<pre><code>&lt;script&gt;\r\nwindow.addEventListener('load', (event) =&gt; {\r\n  lookanalyze_track.goal('checkout-completed'); \r\n});\r\n&lt;\/script&gt;\r\n<\/code><\/pre>\n<h3>Track Form Submissions<\/h3>\n<p>To track form submissions, you can use the <em>onsubmit<\/em> event link like this:<\/p>\n<pre><code>&lt;form method=\"post\" onsubmit=\"lookanalyze_track.goal('contact-form-submit');\"&gt;\r\n<\/code><\/pre>\n<p>If you cannot edit the form code to add an <em>onsubmit<\/em>, but the form has an ID (or you can give the form an ID), you can add the following script after\/below the form:<\/p>\n<pre><code>&lt;script&gt;\r\nwindow.addEventListener('load', (event) =&gt; {\r\n  document.getElementById('form-id').addEventListener('submit', () =&gt; {\r\n    lookanalyze_track.goal('form-submitted');\r\n  });\r\n});\r\n&lt;\/script&gt;\r\n<\/code><\/pre>\n<p>That&#8217;s it! If you have any questions or problems, <a href=\"https:\/\/forms.gle\/R3aZ4qcN57xi8Xvq8\" target=\"_blank\" rel=\"noopener\"><strong>our support team<\/strong><\/a> is here to help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Event tracking allows you to track actions that visitors take on your site, such as button clicks, form submissions, newsletter sign-ups, and any other action that makes sense for your website. Setting up event tracking is very easy. All you have to do is follow these two steps: Create a custom event goal through the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[9],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-features","tag-event-tracking"],"_links":{"self":[{"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":23,"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":143,"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions\/143"}],"wp:attachment":[{"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lookanalyze.com\/blog\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}