LinkedIn Insight Tag : Add specific event code

SOLVE
Florencenoblet
Participant

Hello,

 

I've juste figured out that it's not possible to add short code on button of forms or on CTA. LinkedIn Insight Tag actually provides additional short code to track button submission for example.

 

It's really usefull to be able to add those codes because it allows marketers to analyse how many forms (for example) were submitted with a specific ad on LinkedIn.

 

It should be really useful to add this to Hubspot!

 

Florence

0 Upvotes
1 Accepted solution
derekcavaliero
Solution
Top Contributor | Diamond Partner

@MKl 

 

I would definately fire the pixel/event using Google Tag Manager rather than hard coding it into the form submission callback directly. There are more steps involved to set it up, but having your tracking abstracted in your HTML is a good practice to get into.

 

That being said, what you would want to do is add something like this into the landing page header/footer HTML inside the advanced settings panel:

 

<script>
window.addEventListener('message', function(event) {

    if (event.data.type !== 'hsFormCallback') return;

    if (event.data.eventName === 'onFormSubmit') {
        var dataLayer = window.dataLayer || []; // Ensures the dataLayer is defined to avoid an exception being thrown.
        dataLayer.push({
            event: 'hubspot.form_submit'
        });
    }

});
</script>

 

A couple notes:

  • You'll need to configure a GTM trigger using the "custom event" trigger type that looks for all events with a value of hubspot.form_submit
  • You'll need to configure a tag (Custom Image if using a pixel - Custom HTML if using a javascript event) for the LinkedIn conversion. Attach the trigger mentioned above to that tag.
  • You can add this script into the global header/footer html output in the site settings - doing so would make sure that all your hubspot forms emit the same GTM event when submitted.
  • When using this method - it is advised to make sure your forms are not set to redirect to a thank-you page, otherwise the tracking will not have enough time to execute before the page unloads. There are ways around this - fairly technical and harder to implement - but the easiest thing to do is just set your forms to show an inline message instead of a TY page.

If you need more assistance, shoot me a DM.

Derek Cavaliero
Director, Design/Development

WebMechanix
www.webmechanix.com

View solution in original post

6 Replies 6
derekcavaliero
Solution
Top Contributor | Diamond Partner

@MKl 

 

I would definately fire the pixel/event using Google Tag Manager rather than hard coding it into the form submission callback directly. There are more steps involved to set it up, but having your tracking abstracted in your HTML is a good practice to get into.

 

That being said, what you would want to do is add something like this into the landing page header/footer HTML inside the advanced settings panel:

 

<script>
window.addEventListener('message', function(event) {

    if (event.data.type !== 'hsFormCallback') return;

    if (event.data.eventName === 'onFormSubmit') {
        var dataLayer = window.dataLayer || []; // Ensures the dataLayer is defined to avoid an exception being thrown.
        dataLayer.push({
            event: 'hubspot.form_submit'
        });
    }

});
</script>

 

A couple notes:

  • You'll need to configure a GTM trigger using the "custom event" trigger type that looks for all events with a value of hubspot.form_submit
  • You'll need to configure a tag (Custom Image if using a pixel - Custom HTML if using a javascript event) for the LinkedIn conversion. Attach the trigger mentioned above to that tag.
  • You can add this script into the global header/footer html output in the site settings - doing so would make sure that all your hubspot forms emit the same GTM event when submitted.
  • When using this method - it is advised to make sure your forms are not set to redirect to a thank-you page, otherwise the tracking will not have enough time to execute before the page unloads. There are ways around this - fairly technical and harder to implement - but the easiest thing to do is just set your forms to show an inline message instead of a TY page.

If you need more assistance, shoot me a DM.

Derek Cavaliero
Director, Design/Development

WebMechanix
www.webmechanix.com
MKl
Participant

Hi Derek,

 

This is exactly what I'm trying to do: 

Conversion tracking w/ HubSpot forms gets a bit more tricky as it will likely involve setting up custom javascript event listeners if you aren't using thank you pages (I don't recommend using TY pages for tracking regardless).

 

I'm a novice in code and HTML, can you help me figure out how to do this with the custom javascript event listeners? 

 

Thank you!!

-Marla

0 Upvotes
derekcavaliero
Top Contributor | Diamond Partner

@VGalvis do you need to implement the main tracking script (insight tag) that LinkedIn provides? Or are you trying to implement a conversion event pixel/tag to track form submissions/leads for your campaigns?

 

If its the former - I would highly recommend using something like Google Tag Manager to implement all website tracking code to keep it in an easily auditable and accessible place. If you don't want to spend the time migrating all your tracking to a GTM container - you can add the LinkedIn Insight Tag into the header or footer code output in the pages settings for the particular domain for your portal.

 

Conversion tracking w/ HubSpot forms gets a bit more tricky as it will likely involve setting up custom javascript event listeners if you aren't using thank you pages (I don't recommend using TY pages for tracking regardless).

Derek Cavaliero
Director, Design/Development

WebMechanix
www.webmechanix.com
derekcavaliero
Top Contributor | Diamond Partner

Depending on what you're trying to do - I may have a solution for you. Send me a direct message and maybe I can help you out.

Derek Cavaliero
Director, Design/Development

WebMechanix
www.webmechanix.com
0 Upvotes
VGalvis
Member

Hi Derek,

 

I need to install a LinkedIn Insight Tag in Hubspot to have a better tracking of the campaigns made in LinkedIn, linked to the Hubspot landing pages. Can you help me? I don't know where to insert the tag.

 

Thanks,

Vanessa

0 Upvotes
MauleeChainani
Member

Hi Derek,

 

I am trying to understand how to add event-specific LinkedIn Insights tag to CTA on my landing page. Can you please elaborate on it? 

 

Many Thanks,

0 Upvotes