x

Tracking Events with Google Analytics

I am new to Weebly and would like to add GA event tracking to some files we're offering for download. That means I need to add parameters to the anchor tag, but I can't see a way to get into the code to add them. Is this possible?

Here's an example:

http://toolkit.solarfutures.org/introducing-solar-energy.html

I want to track downloads of all of the files on this page. So I'd like to format the download link like this:

<a onClick="ga('send', 'event', 'PDFfile', 'Downloaded', 'IntroSolar-K-2', '0');" href="http://toolkit.solarfutures.org/uploads/6/6/0/7/66070439/k-2_solar_energy.pdf">

Is there a way to add these parameters? I don't seem to have any code access at all.

Thanks,

~ Laura at GRID Alternatives

6,736 Views
Message 1 of 11
Report
1 Best Answer
Square

Best Answer

Yes, you can add all kinds of code to the Embed Code element - Javascript, HTML, CSS, etc.

View Best Answer >

6,353 Views
Message 2 of 11
Report
10 REPLIES 10

Hey there Laura! 

It looks like you'll want to use an Embed Code element to make the link from custom code. I'm not a coder myself, however, so some of our Community members can likely offer a more detailed explanation.

6,725 Views
Message 2 of 11
Report

Thanks, Queso. So the "Embed Code" element works for any kind of code, not just embeds?

6,358 Views
Message 2 of 11
Report
Square

Best Answer

Yes, you can add all kinds of code to the Embed Code element - Javascript, HTML, CSS, etc.

6,354 Views
Message 2 of 11
Report

Hi Adam,

How do you attach the embed code to a button? I.e. I want to add a GA tag to the button so I can track how many people click on the button. I would usually add the tag code to the file, but in weebly developer mode- I cant find the file uploads anywhere!

There seem to be no answers to this on the entire internet, please help!

Cheers,

Emma

5,549 Views
Message 2 of 11
Report
Square

I figured you might to want to code a button in an Embed Code element so you can add your Google tag code to it like that.

Something like <button googtagcodegoeshere>click here!</button>.  You could probably copy the code for a regular Weebly button and use that as a starting point so it looks the same.

5,547 Views
Message 2 of 11
Report

Hi Adam,

I am having exactly the same question as I also would like to add a GA event tracking code to some of my Weebly buttons. I have tried to use your information to do it, but I am too confused and it is taking too long. All I need is exactly the code for my Weebly button plus where to add the GA event tracking code so I can copy and paste this into the Embed Code on my page. Would you be able to give me that code or point me in a direction where I can find it? (I have searched under my theme's CSS/HTML part and found some button code, but I'm not sure if the code for on the page itself is different than the code in the CSS back-end part. You see I am not a programmer so it all gets confusing. 

The buttons can be found on this home page in the header. 

www.careadvantage.com.au

Any help with this would be appreciated!

5,532 Views
Message 2 of 11
Report
Square

The easiest way to get the code for a button would be to add one to a page of your site, publish, then copy the button HTML code off of the live site. You can then add your tag to that code and paste it into an Embed Code element.

5,525 Views
Message 2 of 11
Report

Did anyone manage to isolate the html code for the weebly button? Using the embed code I hope to be able to add the GA event tracking code to a button (the white text on blue box)? If so, it would be very helpful if this could be posted here. 

Many thanks

Amy 

5,406 Views
Message 2 of 11
Report

imageI think i managed to isolate the code. This provides a dark grey medium sized button. You can easily edit the copy and link (href) as shown above. I'm still working on this and hope to test event tracking using this method tomorrow. If it works i will put it into a quick video tutorial and share on this thread! 

3,650 Views
Message 2 of 11
Report

Can you describe how you'd use the embed code element though to fire an event to google on a button click though?

2,112 Views
Message 2 of 11
Report