About ved decode
The ved decode library consists of:
- simple functions in various languages (currently JavaScript and PHP)—which you can use to decode a ved code into its constituent parameters
- JavaScript code which you can use to decode ved codes and import the data into Google Analytics
- examples of how to go about using the code
The ved_decode functions
Each function is a standalone function that simply decodes the ved parameter and nothing else. It’s not a full-scale protobuf decoder, and we’ve kept the code as simple and as short as possible.
Currently there are implentations in:
ved_analytics.js
You can use ved_analytics.js to decode the ved parameter directly from the document.referrer
Load it like this:
<!-- Include both these scripts or copy them into your main JavaScript file -->
<!--[if lt IE 10]>
<script type="text/javascript"
src="http://veddecode.opensource.dpo.org.uk/js/base64-1.1.min.js"></script>
<![endif]-->
<script type="text/javascript"
src="http://veddecode.opensource.dpo.org.uk/js/ved_analytics-1.1.min.js"></script>
Note that the base64 library is necessary for Internet Explorer 9 and below.
The script sets the global variable VedDecode
which has the following properties:
Property | Description |
---|---|
VedDecode.ved | (object) the raw ved parameter values |
VedDecode.linkIndex | (integer) position of link on page (starting from 1) |
VedDecode.linkType | (string) type of link (e.g. "breadcrumb", "sitelink") |
VedDecode.resultPosition | (integer) number of result on page (starting from 1) |
VedDecode.subResultPosition | (integer) number of sub-result in set of results (starting from 1) |
VedDecode.page | (integer) page of results (starting from 1) |
Please see the example scripts for how to go about importing the data:
- example for Analytics (
ga.js
) - example for Universal Analytics (
analytics.js
)
Copyright and Licence
Copyright 2013 Deed Poll Office Ltd, UK
VED DECODE is free software: you can redistribute it and/or modify it under the terms of the Apache License, Version 2.0 (the "License"). You may not use this work except in compliance with the License.
You should receive a copy of the License in the LICENSE file, along with this program. If not, you can get a copy of the license at: http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.