google analytics event tracking for PDF downloads, Generic approach - google-analytics

I need to implement the GA tracking event for PDF file downloads, For that had searched a lot and found out many code where i can add some code to links and track them from GA's content section, But the problem is I do have a lot of PDF link on the page and don't want to edit every link and I want the code to be generic for future uploaded links also.
So what would be the best approach for this task, Any referral links would do or any code would be highly appreciated .
Thanks in advance.

You can explore the use of Google Tag Manager, where you can create a generic tag that will return to you information for each individual link. GTM uses things called "macros" which is like a template that returns useful information including the clicked element's ID, or pathname (which in your case for the PDF files, would all be different). So in this way, you would only need to call this macro each time a PDF file is clicked. No coding is involved using this standard approach through GTM. Here's a link to a descriptive explanation: http://porcelainduck.com/2014/03/track-pdf-downloads-google-tag-manager/. You can see that it uses the {{element URL}} macro that returns the PDF's unique URL. GTM not only applies to current links, but also all future links.

Based on the tags which you've used to mark your question with you're using C#, ASP.NET
If that's the case, can't you create a base page that on rendering replaces all the

I would recommend adding a click event with JQuery to all links or all links inside the download widget class. Inside the click handler I would then grab the link text and use that as part of the Google analytics event you fire.

Related

Custom Google Form? Example of Google Form API?

I'm trying to make a google form look like my own site. I found examples of how to do this on How to style Google Forms and google-custom-form (GitHub project), but I tried both of the examples they give and they seem to fail now.
I had a look at Class Form - Google Apps Script which seems to be like an API, but I can't get my head around the documentation. Does anyone have an example of it working. Or has found another way of getting this to work? It would be really handy to do as embedded forms look really out of sync with the rest of the site.
The API you're linking to is an apps script API. This is needed if you want to create dynamic forms (dynamic amount of questions, dynamic answers,...) but not for custom styling. An intro to appscript can be found on this page: https://developers.google.com/apps-script/
You could just create a form manually on https://www.google.com/forms/about/
You can change the styling and colors in the top-right of the page. When you are ready to embed the form on your own page you have to press "SEND", an select the embed icon <> at the top.
I've worked with this a ton, and still have issues with it. Been learning the new api v4 for sheets but still having trouble, it is still in beta too. For now I can recommend this solution though by heaversm on github.
https://github.com/heaversm/google-custom-form
The example fully works as long as you find the entry.xxxxxxx for each field and replace in the appropriate js. To avoid the embed issues, give your form submit on a click function that has the event as the input and then preventDefault on the event like so:
$('#submit-button').on('click', function(event){
event.preventDefault();
// continue code from heaversm
});
Hope this works for you. Cheers

Tracking Clicks [Outbound Links] with Autotrack.js

I am trying to find a clear method of tracking clicks to external sites from a site I have built, it appears a lot of information available on this is contradictory or incomplete. I have found autotrack.js on Github which looks like a simpler method, so my question is three-fold, I'll make the question super clear so there is a super clear answer for others in the same conundrum as me.
What snippet/script is added to the HTML and where? I currently have the standard GA snippet for tracking page loads before the </body> tag.
Should I amend / edit the <a> tags to make sense of the who clicked what? I.e. name them, can this be avoided or automated, what I mean is there a script smart enough to name it the same as the destination, like reallygoodlist.com or fb.com/reallygoodlist ?
Is there any GA work required? Set up Goals etc, ideally I would be looking to avoid this - I have a lot of links.
Here is my site (if it helps):
http://www.reallygoodlist.com
1) What snippet/script is added to the HTML and where? I currently have the standard GA snippet for tracking page loads before the tag.
The installation and usage section of the autotrack documentation shows how to install autotrack, so I'll just link to it rather than repeating.
If you're just using the default GA tag, you can probably copy/paste most of the code there, changing the parts relevant to you: e.g. if you only care about outbound link tracking, then only include the outboundLinkTracker plugin.
It also looks like you're installing code via npm, so in this case you can link autotrack's source file in the node_modules directory as you've done with the Babel polyfill.
<script src="node_modules/autotrack/autotrack.js"></script>
2) Should I amend / edit the tags to make sense of the who clicked what ? i.e. name them, can this be avoided or automated, what i mean is ether a script smart enough to name it the same as the destination, like reallygoodlist.com or fb.com/reallygoodlist ?
Autotrack's outboundLinkTracker plugin automatically sets the link's URL as the event label, so you probably don't need to do anything unless that's not enough.
If you want more control than that, setting one of the common options will allow you to custom any data that is sent to GA.
3) Is there any GA work required? Set up Goals etc, ideally I would be looking to avoid this - I have a lot of links.
Not for outbound link tracking. It's just tracking the data as events, so you'll be able to find them in your event reports in GA.

How do I embed code to appear on every product page in shopify?

I am trying to add some Google Analytics related code (addition to the standard code) on every product page. I tried adding it to the bottom of the "product.liquid" file but it doesn't seem to pull through to the live site. Could it be to do with some special Shopify security function that stops unusual looking javascript from being used?
Kind regards,
Benet Hitchcock.
Yes you can do this through your app. You need to take read|write_theme scope at the time of installation of you app now go to theme setting->temeplate editor
Open themes.liquid file and paste your code there
Then its appears on all page

Google Analytics Content Experiment Tracking Code

i'm setting up my first content experiment, and having a single confussion, i tried to search for reference but couldn't find it.
I would like to know if the Content Experiment Code should replace only in single file ? or it Smart Enough to detect which page that need to execute the test ?
Because i'm using wordpress, i can directly place it to header.php under after the opening head tag, but if it only for a single page, i might have to run some if..else statement
Thanks for your feedback
You're supposed to add the content-experiment code snippet to the particular page you want to experiment with, and not the entire website.
From here,
Adding script code to your page
Make sure your original and variation pages have Google Analytics tracking code installed.
Then, paste this experiment code immediately after the opening head tag at the top of your original page.

Use Google Search Appliance Test center as my own aspx page

How would I use the view google has in the test center (where i test my frontend)?
When a user browse to site/search.aspx I want the to get the view testcenter shows, searchboxes and everything. I would also like to add my own javascript and css to the page.
Is this possible?
Now I have created a search box with updatepanel to show the results but this approach will force me to do a lot of parsing and setting variables for the dynamic navigation. I.e. a lot of logic Google already serves in test center.
By the way, I dont want to use the McA+ library supporting GSA 6.14.
I serialized the xml result from the GSA to C# objects and then fed them to my frontend where I could handle them.
Example of converting XML to HTML using XSL in C# ASP.NET can be found at: http://www.codeproject.com/Articles/469723/Rendering-XML-Data-as-HTML-using-XSL-Transformatio

Resources