Send a 'click' to Google Analytics from ruby - ruby

I'm building an app with some 'mail tracking' feature and want to notify google analytics about a click in a link from ruby.
I've already changed all external links from email to go to my server to be redirected, so I know what and when the user clicked.
I want to send this click just knowing the 'UA-XXXXX' and the clicked url.
Is there a way? Or the best solution is to render a html page and with JS send the click event?
UPDATE: Ok, I've found gabba but don't know how to send an 'click' event.

Generally its better to use the JS api, since it has access to all of the other data that analytics tracks, like the visitor browser/os/geoip and can tie all that to a 'visit'.
If you are embedding links in emails, you might consider using the source/medium/campaign flags in the links.
http://support.google.com/analytics/bin/answer.py?hl=en&answer=1033867
So technically its not tracking the 'clicks' as an event, more like tracking the fact that the user came to your site from that particular email. You could use a separate campaign label if you wanted the individual click granularity. (If, for example you had the same url in the email more than once and you wanted to know whether they clicked the first or second one in the email)

Related

How to update an existing activity in WebChat

My scenario is: I send card attachments each with an AcceptButton to users. When 1 user clicks on that button, ideally I want to disable all similar buttons (of the same offer) for all users. I am storing conversation details of each user, and I know the ActivityId of each message-with-said-button (it follows a certain string format).
My issue is similar to this and this but for WebChat not Teams.
I did try those solutions but I got the error "Method not allowed" for both UpdateActivityAsync() and DeleteActivityAsync(). Then I read here that UpdateActivity is not supported in WebChat. (But might be available in the future?)
I would like any visual indication that the offer is no longer available. (Right now, they receive an "Offer was already accepted by {UserX}" which would still be in place on top of changing the card/message.)
Is there a way to do this via backChannel? I can trigger an event and pass the ActivityId (tested by showing a simple alert()) but how do I apply changes to that specific activity?
Per this comment in Web Chat's source code and this open issue in the Web Chat repository for adding support for deleteActivity and updateActivity, Update Activity events are not currently supported in Web Chat. Unfortunately, there is currently no way to really update an activity in Web Chat.
Hope this helps!

Pardot form handler - spam submissions

Hi I have a pardot form handler set up on a website for a client and it is receiving a lot of spam submissions. We set up a honeypot and recaptcha and while they are working, they not seem to be effective in stopping the spam.
We now think the spam submissions are coming from outside our site. I set up a field on our site that sends the url of the page to Pardot when the form is submitted. The ones we sent from our site have the correct url, while the spam submissions don't have the field filled out at all.
Has anyone come across something like this and how did you stop the spam?
I just stumbled across this question now so you may have already got a solution.
If not...
There are bots out there that will be looking for forms that post to Pardot and spamming them. The bot will hit the Form Handler URL directly (e.g go.pardot.com/l/2232) - it will not actually fill in the form on your site.
It seems like you may have already tried to use the Pardot honeypot technique:
https://help.salesforce.com/articleView?id=pardot_forms_add_honeypot.htm&type=0
Alas, this won't really work as the bots aren't filling in those fields.
Some possible solutions:
Use a Pardot Form, instead of a Pardot From Handler, if you can. These forms have additional spam protection.
Instead of your form posting directly to Pardot, send the information to another service first and try to detect spam there. For example, we use Wordpress forms and we clean out spammy enquiries within the Wordpress code before sending it on to Pardot (using CURL). You'll need your web developer to help with this though.
Lastly, use unique "External Field Names", combined with the Honeypot technique listed above. So instead of fields names such as "firstName", "phone" etc, use "web_first_name", "web_phone".
I have come across the same issue - Bots attack Pardot Form Handlers and their URLs.
A bot is scraping our website, looking for the form URL. The later they target precisely this URL separately and that's why captcha or honey pot or anything done on the actual website is not helping!
How did I solved this?
Instead of the form posting to the Pardot Form Handler URL, I changed so that the form is posting to our own server side. Then from our server side we're posting to the Pardot Form Handler URL, but only if the visitor is not a bot.
I've removed the url from the form action and set it dynamically once the submit button is being clicked. That moment, I am combining the url in several steps, e.g.
let actionURL = "https://":
actionURL += "go.company.com";
actionURL += "/1234445457/deeger";
actionURL += "/sdfsddffffd";
$('#subscribeForm').attr('action', actionURL);
$("#subscribeForm").submit();
This prevents the bot from scanning the url on the form in plain text.
If the endpoint url is already compromised, you have to create a new form handler first.

Track button views and clicks as events in google analytics

I am trying to place a button that will be inside email and I want to track button views and clicks (Google Analytics events). Can you tell me if that is possible and how to do that?
You can't technically track a button click from an email, but what you can do is control where the button links to.
If you set the button's URL to point to your servers, you can intercept the link, send a hit to Google Analytics using the Measurement Protocol, and then redirect the user to where the button was originally pointing.
Alternatively, you could append custom campaign parameters to the end of the URL (utm_medium, utm_source, etc.). This would allow you to know what source the hit came from. Here's some information on custom campaigns:https://support.google.com/analytics/answer/1033863?hl=en
This is able to track button views by using Measurement protocol, and using UTM tagging to track sessions come from this button (but not actual clicks).

MvcMailer view in browser

I am using MvcMailer with my website to send html emails.
seems good, but im just wondering how i can view the created emails in a browser.
eg in some newsletters they say "view this email in a browser", so i am just wondering how I can do that with MvcMailer.
The easiest way is to put a link in the email back to your site, and then create a controller/action that uses the same view, and builds a model the same as the one you used when creating the email.
If all the data you need is in the database, you may be able to just pass a key in the querystring (note: if the mail contains potentially sensitive information, make sure the url is tamper-proof), otherwise you might need to pass in more data to allow you to reconstruct the same view that you did when generating the email.

Send unique id to google checkout

I'd like to use google checkout to charge for subscriptions to my website. In order to efficiently process orders, I need to collect the purchaser's email address or another unique id for that order, so that later I can activate their account.
Is there a way to programmatically associate an id that I can generate at runtime with an order placed in google checkout?
If possible, I'd like to do this just by generating different html for the "buy now" button. If necessary, I can use the API.
Update: I see various mentions of merchant-item-id, and when I create a button with Google's tools I can set that field statically. If there were a dynamic way to set merchant-item-id, that would be perfect. Any solutions like that?
Look in to the notification API:
http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API_Notification_API.html
Changing the code of the buy now button wouldn't actually notify you if the order was completed - there'd be no way to determine if a user just loaded the buy now page, completed the payment, or if the payment was declined. With the notification api you can instantly activate the subscription only when payment is received. Of course, you have to write the script to receive the notification...
The only other option I see if changing the continue_url to somehow change the thank you page to include the id, but this is easy to fake.
The answer seems trivial now. Just throw:
<input name="shopping-cart.items.item-1.merchant-item-id" type="hidden" value="11235" />
into your BuyNow button code (or whatever form you're using to submit) with 11235 being any value you like.

Resources