Onclick event - Reserved message

Hi,

I need to add some code to my site to help track, analyse site visitors. Some of the code has been added in the header and footer but I’m told that I also need to add some extra code to track onclick events. Here’s the code:

An example of the code below. I try to create a Custom Attribute in Settings but when enter onClick in the Name Value it says it’s reserved so unable to complete the task.

onClick="track_load(‘http://test.com/about/’, ‘About’)

I came across this article but I don’t know how to configure the workaround suggested for my specific requirements. http://forum.webflow.com/t/google-analytics-event-tracking-for-buttons-in-webflow/8084/4

Any help appreciated.

Thanks

Andy


Here is my public share link: LINK
(how to access public share link)

Did you see callmevlad’s answer for the new solution?

Yes, I think i included a link to it in my post. That solution was talking about Goggle Analytics and I just wanted some direction on how the code should look for the onclick event that I needed and included in my post.

No, you cannot use onclick as an element attribute now, but use custom code instead, which is mentioned in that thread.

Hey jobviddy,

I don’t know if you’re still tacking this problem, but I just posted a new post that I think may answer you question.

Hope it will be of help!

1 Like

Hey benavon, thanks for the message and for creating the code. Have added it to my site and it’s working great, so big thanks to you.

One question if i can please, how can I track the click to start a video embed playing?

Thanks again

I’m sorry but I didn’t quite get what you’re asking.

You want a click on a button to start playing an embedded video?

I have an embedded youtube video on my website. To start the video playing you obviously click the Play button in the middle of the thumbnail.

Is it possible to track the click of that play button using your script?

I got you.
I thought you meant that you had a button somewhere on your site, and you wanted it to be a play button for an embedded video (besides the button on the video itself).

Anyways, to give an answer I need a little bit more information,
like what video provider you use? (YouTube, Vimeo or something else)
If it’s not YouTube or Vimeo, could you please provide a code snippet of the embed?

It’s a youtube video

The short answer is no because YouTube uses iframe to embed it’s videos - this means you don’t have access to specific elements inside the iframe (i.e the play button).

But, there is a workaround that.
Generally, you can create a div and inside of it a thumbnail image of the video with a play button (we’ll refer to it as clone) - when a user clicks the clone’s button the embedded video starts playing (using YouTube’s autoplay embed parameter).

You can put the clone inside a div element along with the embedded video,
and create an interaction which (when the clone’s button is clicked) removes the clone and displays the embedded auto-playing video.

Hope this helps! :smile:

Sounds like it could work, thanks for your help, much appreciated

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.