Are hash referral codes in URL necessary? - drupal

Other sites' referral programs generate url's with hash codes to represent the referrer. When the url is sent to and followed by friends and family, some kind of points or recognition system awards the referrer defined by the hash code...but why the hash code? Why not the user id?

I can see a few reasons:
Obscure the user ID for privacy reasons
Adds an abstraction layer so you can track where the referal came from. e.g. Hash #1 for links from stackoverflow, Hash #2 for links from expert-sexchange (sic), etc...
Security so that a malicious user couldn't simply try all possible user IDs sequentially and rack up a lot of bogus referals - very trivial if the user IDs are simply numbers.

Related

GTM dataLayer restrictions

I am about to send an user's email address via dataLayer.push(), I was wondering if there are any dataLayer restrictions that I should be aware of?
for instance, in Google Analytics, it is not recommended to send email addresses or any PII(Personally identifiable information).
Is it a good idea to send email address, first and last name via dataLayer.push()?
I was not able to get any definitive answers online. Maybe someone can shed a light here. Thanks
Datalayer.push will not do anything with the data except putting it into a variable that is local to the browser. So at this point there is not harm done, and there is not legal or otherwise prohibition to do so (which is what you are asking).
Of course having it on the dataLayer does not do anything by itself.
The question is what you are going to do with the data, and that depends on your jurisdiction (in Europe the GDPR applies, other countries have their own privacy laws) and how the TOS for your tracking tools look like (e.g. in GA you cannot have PII, even if the GDPR or comparable laws do not apply in your country).
But for example if you have consenting users, and storing their email address is essential for delivering the service you are advertising on the page, then pushing this to the dataLayer and using it for your essential purpose should be fine (IANAL).
Also, once the data is in a variable, every other tracking tool that you have implemented on your page can access the value even without your knowledge (but then they can already read it from input fields or other elements in the page code, so that doesn't add much to the danger).

How to show how many people have viewed a post

I have a BBS forum, I just wondered how to count the views of a post?
I need to consider of both registered users and visitors.
I was thinking of counting IPs, but many users or visitors might come from a same IP. Then I am thinking of counting GA (as Google states every _ga lasts for 2 years).
I searched for a while, but have not found any examples.
Your question is too broad, but generally speaking, you'll need some sort of middleware to run as part of the request pipeline and update some data store. If you're looking to discount multiple views by the same individual, then you'll need some sort of discriminator. That's where something like IP address would come in, but as you've mentioned it's not perfect and could end up lumping multiple people into one unit. The best approach is to set an identifier via a cookie, much as GA does with their tracking cookies. That identifier could be anything; it should just be unique for the cookie. Guid.NewGuid() should suffice. Then, you simply record this with the record of the view, and before saving a new record of a view, check for a record with that cookie value, first, if present.
A few things to bear in mind:
Instead of updating a single ViewCount column or something, you should track this in an external table that records the URL that was visited and any discriminating info such as the tracking cookie identifier. When you need to get a full count of views, just aggregate the count from this table. That will remove most of your concurrency worries. Otherwise, you'd have to gate writes to the ViewCount prop, or whatever, which will create choke point for your application.
Even a tracking cookie isn't perfect. For one, it will be device-specific, so the same user will be counted if they visit from both a desktop and mobile device, or even just multiple browsers on the same device. However, there's really not a better option here. If you do have an actual logged in user to work with, you can use that as a potential discriminator to get more exact counts, but of course, you still need a fallback option for anonymous users.

Google Analytics tracking for PDA emails

I have a requirement where I need to track whether a user clicked a link in a PDA email where the link included in the email is >900 characters.
I'm not sure if Google analytics support tracking in PDA.
If anyone has ever done this,please help me out.
Thanks
I seem to have misunderstood the question, so here is an update. Google will usually track any valid Urls. The two exceptions I can think of are more theoretical than a practical concerns.
Some old browsers (I think IE6 and similar vintages) have a character limit for GET requests (2048 bytes IIRC), so very long links will not work, and this not be tracked correctly. For all practical purposes these browsers should be extinct by now
A Google Analytics request is limited to 8096 bytes.The request has to transmit the document location as part of the payload, so if your URL is really massively oversizes (technically 8000 characters is ">900") this would not be tracked. Again, this is hardly a practical concern (unless there is a lot of other data, like e.g. Enhanced E-Commerce product impressions in that request).
Old (and probably irrelevant) answer:
Google Analytics does typically not track actions within emails, since email clients do not usually support javascript (there are implementations of email open tracking via "web bugs" linked to a script that does a measurement protocol request, but event that does not work particularly well).
If this is a link that points to your homepage the typical way to track this would be via utm parameters - i.e. you do not track the action within the email itself, but the result (the visit to your homepage).
UTM parameters (or "campaign parameters") are
utm_medium - the kind of traffic (if it's paid advertising, banner ads, or in your case e.mail)
utm_source - the specific vendor (e.g. "google" if the link is from a paid Google Ad, or in your case it could be the name of the department that sent out the mail)
utm_campaign - your advertising campaign; in the case of a periodic newsletter this could be e.g. the number of the newsletter
utm_term - you usually would not use that in an email, that's reserved for when a link is a result of a search (then you would insert the search term)
utm_content - if you have multiple links with the same link target and campaign info you can add additional information (e.g. if you have the same link at the top and the bottom of your mail you could indicate the position here)
You cannot do anything dynamic, though - if you want to mark links with a specific character count you would have to do this within your newsletter programm and insert the number. GA would then be able to pick this up from the campaign parameters.
E.g. for your use case you might construct a target URL like
www.example.com?utm_medium=email&utm_source=my_department&utm_campaign=pda_mail&utm_content=<number of characters>
and then get the information from the Aquisition reports in Google Analytics.
If the links do not point to your own homepage you would need to set up an intermediate page that tracks the utm_parameters before it redirects to the intended destination.

Google+ userId into google analytics for attribution modeling

Due to the nature of my website, it is very complex to get a proper attribution model, cross device tracking is complex but necessary.
I would like to know if it is possible to obtain somehow a users google+ userId whenever he visits my site.
I know there is a feature called UserId where I need to generate my own ID and track it upon a customers visit, but due to the nature of my website, there is very little probability they will log in prior to converting (Fact which will make every cross device interaction useless).
You cannot use a Google ID as the User ID in Google Analytics. The User ID must be private and non PII, i.e. Google must have no way to determine who that ID belongs to. Obviously if it's a Google-based ID, they would be able to tell pretty easily.
The relevant bit from the TOS is paragraph 7 :
You will not (and will not allow any third party to) use the Service
to track, collect or upload any data that personally identifies an
individual (such as a name, email address or billing information), or
other data which can be reasonably linked to such information by
Google.

Is there any non-valid contents for a referer field?

I'd like to know the identities of users who come to my website by clicking on a link in my native application.
Could my app populate the referer field with a unique user ID?
Does the referer field have to be a valid URL?
Will Google Analytics handle a referer that isn't a URL?
I could mockup a URL like http://www.user.com/656 where 656 is the user ID.
Any caveats?
Good question. On one hand, i have remapped quite a few of these GA Fields (including Referral) and i have never had a problem. In addition, doing so is core functionality in GA (see below); in other words (as i am sure you know) GA actually provides its users with the templates (via Advanced Filters) to munge these Fields beyond recognition. )
On the other hand, i can think of one situation (only one actually) in which i believe Google would object and that's the case where the replacement information violates the GA Privacy Policy. In particular, displaying or storing or tracking via GA any personally identifiable information violates the Policy [italics are mine, not a quote from the GA Privacy Policy].
The actual definition from Google:
Personal information is information
that personally identifies you, such
as your name, email address or billing
information, or other data which can
be reasonably linked to such
information
Is a unique user ID, personally identifiable information? There is a difference between data intended to clearly distinguish one user from another, and data intended to identify each user. The distinction might depend on security--i.e., how easily could someone who had in their possession a list of your unique user IDs, discover the user identifies behind them?
Technically, the referrer header just specifies a URL. If you want to construct "fake" URLs, come up with a URI scheme specific to your application. Something like userid:656.

Resources