Google Analytics Goal for selecting text on web page - javascript

I have a project page at http://fulldecent.github.io/cameralife/ and some users will "convert" by selecting this text on the page:
git clone https://github.com/fulldecent/cameralife.git
And hopefully they will paste this into a terminal :-)
I am looking for advice on how to fire a Google Analytics goal when this text is selected. Right now I am working with:
Attach to mouseup
Check createRange or window.getSelection
Fire Analytics goal
That technique is at: Selected text event trigger in Javascript
This approach is from 2010, and wanted to ask first. Is this the best approach with HTML5 or should I be using a more modern approach?

I would suggest looking at CopyPaste by Tynt. The main purpose is different (inserting your URL to copied text), but why wouldn't it allow firing an trackEvent request, which would subsequently record a conversion (assuming you would set up goal tracking based on specific event occurrence)

Related

Adding text to clipboard (or pasting to cursor) in Chrome extension V3

I'm building extension for Chrome using manifest V3. Interaction I'm trying to achieve is:
User clicks a button in context menu.
Extension communicates with the server and receives some string in response.
User clicks another button in context menu and said string gets pasted where their cursor is.
I see two ways I could achieve it and I'm not sure which one makes more sense (or how to get either to work, really):
One would be to have said string put into clipboard and then have user access it with paste command.
Second would be to have a separate context menu button which upon pressing pastes the string where the cursor is.
Either solution would work for me, however I prefer one that asks for less permissions from user (I'm already accessing storage, requests and context menus). So far I was also able to avoid using background workers and event pages, which provided some convenience when working with context menus - I'd like to keep it that way, but I'd rather have my extensions actually working ^^
Unfortunately Chrome documentation is rather confusing, bordering on circular, when explaining how to achieve something like this, especially within Manifest V3. How do I go about it?

Custom Click tracking for Vuejs

Here is a problem I am facing. I want to build a podcast recommendation engine and wanted some behavior click information. Here is the app https://podflix.app
What is the source page or the podcast ID
And which podcast or recommendation people clicked for a given source podcast.
Also what tracking library to use for custom json tracking? I am currently using google analytics but can't send custom json in events data.
Is there a way to get this information tracked automatically?
I recommend you use Google Tag Manager for this. Look into auto event variables in GTM.
Then look at click triggers and event tracking in GTM. Tie these together you should be able to form a solution. Give it a try and let me know if you run into issues.
Example,
For podcast id you would create a link click trigger and register the GA event to track the "href" of the link in the event label.

Using ExitAPI in a HTML5 ad banner with parameters

I have created a banner for Adwords, using HTML5 with a form element, which accepts few inputs, like your preffered color, type, etc.
The whole banner is not clickable, only the submit button, which I achieved by adding "onclick="ExitApi.exit()"" to the button.
All of this works fine, but now my question is, how flexible is this ExitApi?
Whenever I click the submit button, I want to append the generated parameters to the final url, which is set through AdWords.
Using the adwords preview I can see that during the redirect the last parameter is 'adurl' which contains my final destination.
Editing this manually and just typing in the parameters helps me achieve what I want, but how would I be able to append using the ExitApi js library, if that's even possible?
I also tried using a CTA through GWD using something like 'gwd.actions.gwdDoubleclick.exitOverride('gwd-ad', 'clickTag', 'http://example.com/index.php?some=var'+params, true, true);', which hasn't worked and is also limiting as it forces the developer to set the url through the banner.
Any ideas are appreciated!
Thanks,
Edvinas
If anyone is stuck on this aswell, just an update.
I have contacted Google Adwords Support about this and here's their response:
Unfortunately, multiple exit URLs are not supported in the AdWords environment. Doubleclick, on the other hand, can handle them.
https://support.google.com/webdesigner/answer/4450409
There are many nice components in GWD which could use different URLs, but they can't be deployed in AdWords.

Universal analytics added with Google Tag Manager shows real-time events but not historical

I'm using Google Tag Manager to add Universal Analytics to a page and triggering an event with the JavaScript API. I'm able to the see the event being sent using GA Debugger and on the "Real-Time -> Events" page in GA but it never seems to make it to the "Behaviour -> Events" page (no filters or segments on). The page has been live for about 2 months so I would have thought the raw data would be well and truly processed by now. Is anyone able to provide any insight on why this is happening?
I had a similar issue. Mine was resolved by changing the default tracking period from the default in the calendar (top right) on the Events Overview -page.
I came across this 'issue'.
I had integrated google tag manager into my site, and could see that the events were showing in realtime, but not in the historical data for behaviours/events.
The solution was, looking a the calendar. The historical events for me were, by default, looking at the previous months events. This makes sense then that the real time data I was seeing was not showing.
Below is the image of my realtime events coming through.
And here is an image of what I was seeing by default in the historical events view.
The day these images were taken was the 30th January 2017, as you can see, the calendar at the top right of the events graph is searching through December. Aha... makes sense now why the events are not showing right?
So I clicked the calendar, to change the date period being searched by the events graph and set it to my desired range, in this case, I set it to search for this Month (January), as I had only just implemented the tag manager logic.
Low and behold, after clicking apply on this new date range, the events appeared as I expected them to.
I'm unsure if this answers the OP's specific issue but this is what solved it for me.

What is the best way to modify a specific field in a form?

Specifically what I'd like to do is "alter" one of the fields in the Google Calendar field entry for my own purposes. Namely the location is almost always going to be one of four locations, but the way the Google Calendar is set up it doesn't track frequently entered information, and writing the full address every time (or keeping a notefile w/ the 4 addresses to C&P) is kind of annoying.
Ideal I suppose would be an "extension" or script that would automagically detect that I'm filling out a Google Calendar event entry and change the location field to a drop with the four addresses I frequently use as well as an "other" option.
Another possibility might be some kind of bookmarklet (or set of 4) that fills the location field in.
I don't really know where to start or which method would be better (hell, there might well be a third option that is superior).
PS: If this would be easier/more efficiently done in Firefox or some other browser rather than Chrome that is fine as well.
I'd go with bookmarklets. Here's a potential URL for setting addresses given the current Google Calendar page (the id of the "Where" input is ":1u"):
javascript:document.getElementById(':1u').value='123 Some st.'; void(0);
I'd write bookmarks with URLs similar to the above for each of your 4 addresses and then put them into an easily accessible folder, and use them each time you want to populate that address.
UPDATE:
Since the ID changes, you can get it by the class name. However, if the class changes or the number of inputs before the Where field changes, you'll have to update your links:
javascript:document.getElementsByClassName('textinput')[1].value='123 Some st.'; void(0);
UPDATE 2:
Apparently Google doesn't consider the current value of the textbox when a Calendar item is saved. I fixed this by manually firing the 'change' event after the value of the textbox is updated. The following currently works in Firefox:
javascript:var a=document.getElementsByClassName('textinput')[1];a.value='123 Some st.';var e=document.createEvent("HTMLEvents");e.initEvent('change',true,true);a.dispatchEvent(e);void(0);

Categories