Jump to content

How to track button clicks with Google Analytics event tracking?

Recommended Posts

Does anyone know how to do this? I don't need to track a form submission, I need to track individual button clicks.

Edited by Guest
Initial Revision
Link to comment

I figured out how to do this!

Instead of using a "button" block, use the "custom code" block. Add a link using html where you want the button to go:


<a href="/order-now" class="custom-button-black" onClick="ga('send', 'event', { eventCategory: 'order_now', eventAction: 'button_click', eventLabel: 'section_intro'});"
>Order Now</a>

  • The link will take uses who click the button to my "order now" pag
  • In "class" we assigned the link the "custom-button-black" class.
  • The third part of the link is the GA tracking code

    Now we'll create a button in the custom CSS panel for that class.

Add this code in the custom CSS panel:


.custom-button-black {
 display:block;
 margin:auto;
 width: 25%;
 height: auto;
 background-color:black; 
 color: white;
 text-align: center;
 vertical-align: middle;
 line-height: 50px; 
 border-radius: 3px;
 letter-spacing: 1px;
 font-family: "proxima-nova";
 font-size: 10px;
 text-transform: uppercase;
 letter-spacing: .2em;
 font-weight: 600;
 font-style: normal;
}







Link to comment
  • 2 weeks later...
  • 1 year later...

Paid plugin also available

If you're frustrated with tutorials and want a quick solution that definitely works, check out Squarespace Click Traking Plugin.

It's a paid solution, but a few dollars also makes it 100% sure to work. Money back if it doesn't and 1-on-1 support provided if you have any problems.

The Squarespace Button Block is basically a link as any other, so link tracking is what you need. And it's what our plugin does. The plugin tracks outbound links, internal links, file downloads, button links, social media links etc.

Edited by voxpopagency
Initial Revision

Freelance Squarespace developer making plugins like Full-Width Blocks, Hover effects for grid gallery and the Darkmode plugin. I know Squarespace inside out and I'm able to solve pretty much any Squarespace code problem.

Get in touch here!

Link to comment
  • 8 months later...
  • 8 months later...
On 11/1/2018 at 12:29 PM, voxpopagency said:

Paid plugin also available

If you're frustrated with tutorials and want a quick solution that definitely works, check out Squarespace Click Traking Plugin.

It's a paid solution, but a few dollars also makes it 100% sure to work. Money back if it doesn't and 1-on-1 support provided if you have any problems.

The Squarespace Button Block is basically a link as any other, so link tracking is what you need. And it's what our plugin does. The plugin tracks outbound links, internal links, file downloads, button links, social media links etc.

Unfortunately, the tracking plugin link was broken after I paid. I'm troubleshooting with them.

Link to comment
  • 2 weeks later...
  • 11 months later...
On 4/15/2020 at 6:28 PM, martinezlorna13 said:

Glad to hear it!

I'm going to be working on more solutions to this and will try and write more tutorials on this. Not enough info on Squarespace, Google Analytics and Tag Manager (all of which I'm specialized on).

Google Tag Manager is perhaps overkill if it's only for few button clicks.

But now that new Google Analytics 4 is out, our Click Tracking Plugin doesn't yet support that so GTM is the way to go. Will update the plugin soon. 

For any custom button/form/link tracking stuff I can also help 1-on-1:

 hire {ä} codeandtonic.com

Edited by codeandtonic
formatting

Freelance Squarespace developer making plugins like Full-Width Blocks, Hover effects for grid gallery and the Darkmode plugin. I know Squarespace inside out and I'm able to solve pretty much any Squarespace code problem.

Get in touch here!

Link to comment
  • 2 years later...
On 4/3/2021 at 8:45 AM, codeandtonic said:

Glad to hear it!

I'm going to be working on more solutions to this and will try and write more tutorials on this. Not enough info on Squarespace, Google Analytics and Tag Manager (all of which I'm specialized on).

Google Tag Manager is perhaps overkill if it's only for few button clicks.

But now that new Google Analytics 4 is out, our Click Tracking Plugin doesn't yet support that so GTM is the way to go. Will update the plugin soon. 

For any custom button/form/link tracking stuff I can also help 1-on-1:

 hire {ä} codeandtonic.com

Has this been updated yet please?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.