Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging Downloads for Tracking #1121

Closed
ZibbyKeaton opened this issue Feb 1, 2017 · 11 comments
Closed

Tagging Downloads for Tracking #1121

ZibbyKeaton opened this issue Feb 1, 2017 · 11 comments

Comments

@ZibbyKeaton
Copy link
Contributor

All -
I am trying to better track how many folks are downloading our case studies on the Node.js Foundation site to determine if folks are downloading these and find them helpful. You can find the case studies in the Node.js Foundation resource section here: https://nodejs.org/en/foundation/case-studies/.

I would like to track this all through Google analytics. I talked to someone from the Linux Foundation marketing team and they set us up with event tracking, but I'm having some trouble figuring out exactly how to retag each of these case studies and upload it to the website via GitHub. Hopefully this makes sense.

I was wondering if anyone has experience with this in the group and might be able to help me here. Even if you show me how to do just one, I can probably do the rest on my own.

Thanks for helping me with this!

Here's a link to what I'm talking about: https://support.google.com/analytics/answer/1012044?hl=en#Download

@mikeal
Copy link
Contributor

mikeal commented Feb 2, 2017

Looks like we'd need to add some meta info the tag.

Because the HTML for that is made by the markdown parse the easiest thing is probably to insert some script into the template for that page to add it rather than trying to hack up the markdown parser for the just that page.

@ZibbyKeaton
Copy link
Contributor Author

So something like this: <a href="https://nodejs.org/static/documents/casestudies/Node_CaseStudy_Walmart_final.pdf"onClick="ga('send', 'event', { eventCategory: 'casestudy', eventAction: 'click', eventLabel: 'Walmart Case Study', eventValue: 0});">Read the full case study.

This would link it directly back to our google analytics for tracking...

@danielkhan
Copy link

Maybe using Google Tag Manager would help. It lets you add tracking events to actions without touching the code. Setting it up requires a bit of work but less than hacking the code I guess https://support.google.com/analytics/answer/6163791?hl=en

@ZibbyKeaton
Copy link
Contributor Author

Yes, we have that @danielkhan. Just looking to figure out how we can upload this HTML code into GitHub to make sure it's tracking. That's where I'm having some issues as I'm unsure where I would specifically do this in GitHub's interface.

@danielkhan
Copy link

I see - so GTM is in place already, right?

@ZibbyKeaton
Copy link
Contributor Author

Yes, everything is set in Google Analytics and we are trying to track these as events, however I need to figure out how to embed HTML on our site to ensure that we are able to track. So it's all set on Google Analytics, now we need to match the code with the page. I hope that makes sense. This is new to me and something that I haven't dealt with before. @danielkhan

@ZibbyKeaton
Copy link
Contributor Author

@mikeal is this something that you can help with?

@phillipj
Copy link
Member

phillipj commented Feb 3, 2017

@ZibbyKeaton sorry for not seeing this earlier.

The file you are looking for is locale/en/foundation/case-studies.md.

I've done some testing locally, and found that markdown links can be translated to HTML links (<a>) which allows you to add the onClick handler you're looking for. Using Walmart as an example:

Replace

[Read the full case study.](/static/documents/casestudies/Node_CaseStudy_Walmart_final.pdf)

with

<a href="/static/documents/casestudies/Node_CaseStudy_Walmart_final.pdf" onClick="ga('send', 'event', { eventCategory: 'casestudy', eventAction: 'click', eventLabel: 'Walmart Case Study', eventValue: 0});" target="blank">Read the full case study.</a>

Notice I've added target="blank" in addition to your example. That's because browser often will cancel the request to Google if it has been told follow link, in this case download the .pdf.

Hope that makes sense, if not don't hesitate to ask 😃

@ZibbyKeaton
Copy link
Contributor Author

Thank you so much @phillipj I went in there to make the change. I want to test Walmart out before I do it with the other case studies. I don't know if you are able to merge my change or whatever might be next, but let me know and then I can test in our Google Analytics to make sure it is all working well before I do this with the others.

@phillipj
Copy link
Member

phillipj commented Feb 3, 2017 via email

@ZibbyKeaton
Copy link
Contributor Author

ZibbyKeaton commented Feb 3, 2017

Just created a PR and tagged you in it @phillipj LMK if that works....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants