How can I track a button click or pop-up within Leadinfo

Companies often use forms that are embedded in their page or create pop-ups where website visitors can subscribe to their newsletter. These forms or pop-ups are not tracked by Leadinfo because the URL does not change. But no need to worry! If you follow the below steps, you can still track companies that submitted a form or subscribed to a newsletter.


But before you start, you need to install the tracking code on your website and have access to the source code of your website or to Google Tag Manager.

How can I track (click) events in Leadinfo?


You can track events in two different ways. You can manually add a script to the event you'd like to track.


For example, if you want to track which companies clicked on the contact button you need to add the below script to the code of the button.


When a website visitor clicks on the contact button, Leadinfo will register this click as a page view. The page view will be shown as '/contact-button'. If you want to adjust the name of the page view, replace /contact-button with another text.


Login example:

<script>
if(window.leadinfo) {
window.leadinfo('setCustomUrl', '/contact-button');
window.leadinfo("trackPageView");
}
</script>

 

How can I track events using Google Tag Manager


If you do not have access to the source code of your website, you can also use Google Tag Manager to track events in Leadinfo. How does it work? Well, in short: to get started you will need to identify the variable your event sends to Google Tag Manager. Based on this variable you can create a trigger with in Google Tag Manager that fires a custom HTML tag, containing a script that allows Leadinfo to show the event as a page view within Leadinfo. 


But that's the short version. Follow the steps below to set this all up within Google Tag Manager.

 

Step 1: Identify the variable of your event

First, you need to know what variable you can use to base your trigger on. Ask your developers to add unique click ID's to all the buttons on your website. These are the most common and easiest variables to create trigger on:

 

Click URL: Refers to the URL you're navigated to when you click on a button or link

Click Text: Refers to the text you click on when you click on a button or a link.


An example: We want to track all the companies that clicked on a button to download a PDF. A unique variable would be the Click URL. Because the click URL would always contain ".pdf".

Step 2: Create a trigger based on your variable


Based on the variable you identified you can start setting up your trigger. In Google Tag Manager, navigate to “Trigger” in the left menu. Create a new trigger and select below “Click” the trigger type “All elements”. Select “Some elements” and select the variable you identified in step 1. 


To continue with the above example. You can set up your trigger as shown below.

 

 

Step 3: Create a tag and assign it to the trigger

Once you've created the trigger, you can set up your Tag. Select "Tag" on the left side menu and select "Customer HTML" as your tag type.

Paste the below script in your tag. You only need to change "SET-YOUR-CUSTOM-URL" in the script to a URL of your own choosing.  Please note: Always use a hyphen (-) to separate the words.

<script>
if(window.leadinfo) {
window.leadinfo('setCustomUrl', '/SET-YOUR-CUSTOM-URL');
window.leadinfo("trackPageView");
}
</script>

 

Below the tag configuration, click on "Triggering" and select the trigger you've created in step 2.

 

Leadinfo Tip 💡 Instead of setting a custom URL such as /pdf-download, you can also set variables as a page view within Leadinfo. For example if you place {{Click URL}} in the script, it will show the Click URL as a page view within Leadinfo. 

Please check the correct name in your language if you have set your language other than English.

 

Step 4: Save your changes and publish the latest version

Do not forget to save your changes and submit your latest version to your live website. Click on "Submit" in the top right corner to publish your changes.