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.
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.
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?
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.