Brian T Hannan
Brian T Hannan

Reputation: 4015

How do I pass a parameter from my site into google analytics?

Let's say I have a site and the user comes into it with a parameter:

http://example.com&url=blahblahblah

How do I go about passing along the url value from the parameter into Google Analytics?

1) User comes to the page with a url in the params

2) User clicks a download link with a ga tracking code attached to it which was generated from ga account like this:

http://example.com/download/param1=dkljdf&_ga=1.149898996.39207121.1424368466

Upvotes: 0

Views: 1906

Answers (1)

You have to create a custom Dimension and a metric for that.

About custom Dimensions and metrics: https://developers.google.com/analytics/devguides/platform/customdimsmets

After you have created a Dimension, you can add metrics to it by view, in example.

Follow the steps here for Universal Analytics: https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

Note that due to not have 10 point of reputation, I wrote the a "_" in http like "ht_tp"

BUT: I think what you want to know is the number os visitors that clicks a download link in your site that comes from, lets say "blahblahblah" as web origin or other methods. For that, you have the param utm_source that you can receive directly in the url. So instead of ht_tp://example.com&url=origin you should receive ht_tp://example.com&utm_source=origin

In this way, you have no care about it. Analytics is going to take care for you so you can get a report of clicks by source.

Or, just use the referer in case all the incoming visitors are from webs: ga('set', 'referrer', 'ht_tp://example.com');

And a final option, to use Events: _gaq.push(['_trackEvent', 'ReferencedVisitors', jsVarWhereYouHaveTheOrigin]);

Upvotes: 1

Related Questions